Merge branch 'dev' into dynamicIdx
This commit is contained in:
commit
345d92d073
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG ff7de07
|
||||
GIT_TAG e07f41b
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 823fae5
|
||||
GIT_TAG e62c5ea
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -185,6 +185,7 @@ DLL_EXPORT void taos_kill_query(TAOS *taos);
|
|||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res);
|
||||
|
||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
|
|
|
@ -249,10 +249,11 @@ typedef struct SColumnInfoData {
|
|||
|
||||
typedef struct SQueryTableDataCond {
|
||||
uint64_t suid;
|
||||
int32_t order; // desc|asc order to iterate the data block
|
||||
int32_t order; // desc|asc order to iterate the data block
|
||||
int32_t numOfCols;
|
||||
SColumnInfo* colList;
|
||||
int32_t type; // data block load type:
|
||||
int32_t* pSlotList; // the column output destation slot, and it may be null
|
||||
int32_t type; // data block load type:
|
||||
STimeWindow twindows;
|
||||
int64_t startVersion;
|
||||
int64_t endVersion;
|
||||
|
|
|
@ -41,9 +41,9 @@ typedef struct SBlockOrderInfo {
|
|||
BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
|
||||
} while (0)
|
||||
|
||||
#define colDataSetNotNull_f(bm_, r_) \
|
||||
do { \
|
||||
BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_))); \
|
||||
#define colDataClearNull_f(bm_, r_) \
|
||||
do { \
|
||||
BMCharPos(bm_, r_) &= ((char)(~(1u << (7u - BitPos(r_))))); \
|
||||
} while (0)
|
||||
|
||||
#define colDataIsNull_var(pColumnInfoData, row) (pColumnInfoData->varmeta.offset[row] == -1)
|
||||
|
@ -151,9 +151,6 @@ static FORCE_INLINE void colDataAppendNNULL(SColumnInfoData* pColumnInfoData, ui
|
|||
for (int32_t i = start; i < start + nRows; ++i) {
|
||||
colDataSetNull_f(pColumnInfoData->nullbitmap, i);
|
||||
}
|
||||
|
||||
int32_t bytes = pColumnInfoData->info.bytes;
|
||||
memset(pColumnInfoData->pData + start * bytes, 0, nRows * bytes);
|
||||
}
|
||||
|
||||
pColumnInfoData->hasNull = true;
|
||||
|
@ -234,9 +231,11 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
|
||||
int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock);
|
||||
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
|
||||
|
||||
|
|
|
@ -64,6 +64,11 @@ extern int32_t tsNumOfSnodeStreamThreads;
|
|||
extern int32_t tsNumOfSnodeWriteThreads;
|
||||
extern int64_t tsRpcQueueMemoryAllowed;
|
||||
|
||||
// sync raft
|
||||
extern int32_t tsElectInterval;
|
||||
extern int32_t tsHeartbeatInterval;
|
||||
extern int32_t tsHeartbeatTimeout;
|
||||
|
||||
// monitor
|
||||
extern bool tsEnableMonitor;
|
||||
extern int32_t tsMonitorInterval;
|
||||
|
@ -126,9 +131,9 @@ extern char tsUdfdResFuncs[];
|
|||
extern char tsUdfdLdLibPath[];
|
||||
|
||||
// schemaless
|
||||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
extern bool tsSmlDataFormat;
|
||||
extern char tsSmlChildTableName[];
|
||||
extern char tsSmlTagName[];
|
||||
extern bool tsSmlDataFormat;
|
||||
extern int32_t tsSmlBatchSize;
|
||||
|
||||
// wal
|
||||
|
@ -146,7 +151,7 @@ extern int32_t tsUptimeInterval;
|
|||
extern int32_t tsRpcRetryLimit;
|
||||
extern int32_t tsRpcRetryInterval;
|
||||
|
||||
//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||
|
||||
int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd,
|
||||
const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc);
|
||||
|
|
|
@ -66,6 +66,10 @@ extern int32_t tMsgDict[];
|
|||
|
||||
typedef uint16_t tmsg_t;
|
||||
|
||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||
(type == TDMT_VND_UPDATE_TAG_VAL);
|
||||
}
|
||||
/* ------------------------ OTHER DEFINITIONS ------------------------ */
|
||||
// IE type
|
||||
#define TSDB_IE_TYPE_SEC 1
|
||||
|
@ -1405,8 +1409,8 @@ typedef struct {
|
|||
int8_t streamBlockType;
|
||||
int32_t compLen;
|
||||
int32_t numOfBlocks;
|
||||
int32_t numOfRows;
|
||||
int32_t numOfCols;
|
||||
int64_t numOfRows; // from int32_t change to int64_t
|
||||
int64_t numOfCols;
|
||||
int64_t skey;
|
||||
int64_t ekey;
|
||||
int64_t version; // for stream
|
||||
|
|
|
@ -43,7 +43,6 @@ typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg);
|
|||
typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
|
||||
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
||||
typedef void (*SendRedirectRspFp)(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg);
|
||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
|
||||
typedef void (*ReportStartup)(const char* name, const char* desc);
|
||||
|
@ -55,7 +54,6 @@ typedef struct {
|
|||
GetQueueSizeFp qsizeFp;
|
||||
SendReqFp sendReqFp;
|
||||
SendRspFp sendRspFp;
|
||||
SendRedirectRspFp sendRedirectRspFp;
|
||||
RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
|
||||
ReleaseHandleFp releaseHandleFp;
|
||||
ReportStartup reportStartupFp;
|
||||
|
@ -66,7 +64,6 @@ int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg);
|
|||
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype);
|
||||
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||
void tmsgSendRsp(SRpcMsg* pMsg);
|
||||
void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
|
||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
|
||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type);
|
||||
void tmsgReportStartup(const char* name, const char* desc);
|
||||
|
|
|
@ -278,11 +278,9 @@ typedef struct {
|
|||
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
|
||||
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
|
||||
#define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX)
|
||||
#define IS_VALID_BIGINT(_t) ((_t) >= INT64_MIN && (_t) <= INT64_MAX)
|
||||
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) <= UINT8_MAX)
|
||||
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) <= UINT16_MAX)
|
||||
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) <= UINT32_MAX)
|
||||
#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) <= UINT64_MAX)
|
||||
#define IS_VALID_FLOAT(_t) ((_t) >= -FLT_MAX && (_t) <= FLT_MAX)
|
||||
#define IS_VALID_DOUBLE(_t) ((_t) >= -DBL_MAX && (_t) <= DBL_MAX)
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef struct SInputData {
|
|||
|
||||
typedef struct SOutputData {
|
||||
int32_t numOfBlocks;
|
||||
int32_t numOfRows;
|
||||
int64_t numOfRows; // int32_t changed to int64_t
|
||||
int32_t numOfCols;
|
||||
int8_t compressed;
|
||||
char* pData;
|
||||
|
|
|
@ -137,22 +137,22 @@ typedef struct SqlFunctionCtx {
|
|||
int16_t functionId; // function id
|
||||
char *pOutput; // final result output buffer, point to sdata->data
|
||||
int32_t numOfParams;
|
||||
SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param
|
||||
SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/
|
||||
int32_t offset;
|
||||
struct SResultRowEntryInfo *resultInfo;
|
||||
SSubsidiaryResInfo subsidiaries;
|
||||
SPoint1 start;
|
||||
SPoint1 end;
|
||||
SFuncExecFuncs fpSet;
|
||||
SScalarFuncExecFuncs sfp;
|
||||
struct SExprInfo *pExpr;
|
||||
struct SSDataBlock *pSrcBlock;
|
||||
struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity
|
||||
SSerializeDataHandle saveHandle;
|
||||
bool isStream;
|
||||
|
||||
char udfName[TSDB_FUNC_NAME_LEN];
|
||||
// input parameter, e.g., top(k, 20), the number of results of top query is kept in param
|
||||
SFunctParam *param;
|
||||
// corresponding output buffer for timestamp of each result, e.g., diff/csum
|
||||
SColumnInfoData *pTsOutput;
|
||||
int32_t offset;
|
||||
SResultRowEntryInfo *resultInfo;
|
||||
SSubsidiaryResInfo subsidiaries;
|
||||
SPoint1 start;
|
||||
SPoint1 end;
|
||||
SFuncExecFuncs fpSet;
|
||||
SScalarFuncExecFuncs sfp;
|
||||
struct SExprInfo *pExpr;
|
||||
struct SSDataBlock *pSrcBlock;
|
||||
struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity
|
||||
SSerializeDataHandle saveHandle;
|
||||
char udfName[TSDB_FUNC_NAME_LEN];
|
||||
} SqlFunctionCtx;
|
||||
|
||||
typedef struct tExprNode {
|
||||
|
@ -183,7 +183,6 @@ struct SScalarParam {
|
|||
};
|
||||
|
||||
void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell);
|
||||
//int32_t getNumOfResult(SqlFunctionCtx *pCtx, int32_t num, SSDataBlock *pResBlock);
|
||||
bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry);
|
||||
bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry);
|
||||
|
||||
|
@ -195,32 +194,6 @@ typedef struct SPoint {
|
|||
int32_t taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint *point1, SPoint *point2,
|
||||
int32_t inputType);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// udf api
|
||||
/**
|
||||
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
|
||||
* @return error code
|
||||
*/
|
||||
int32_t udfcOpen();
|
||||
|
||||
/**
|
||||
* destroy udfd proxy
|
||||
* @return error code
|
||||
*/
|
||||
int32_t udfcClose();
|
||||
|
||||
/**
|
||||
* start udfd that serves udf function invocation under dnode startDnodeId
|
||||
* @param startDnodeId
|
||||
* @return
|
||||
*/
|
||||
int32_t udfStartUdfd(int32_t startDnodeId);
|
||||
/**
|
||||
* stop udfd
|
||||
* @return
|
||||
*/
|
||||
int32_t udfStopUdfd();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -85,6 +85,32 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols,
|
|||
|
||||
int32_t cleanUpUdfs();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// udf api
|
||||
/**
|
||||
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
|
||||
* @return error code
|
||||
*/
|
||||
int32_t udfcOpen();
|
||||
|
||||
/**
|
||||
* destroy udfd proxy
|
||||
* @return error code
|
||||
*/
|
||||
int32_t udfcClose();
|
||||
|
||||
/**
|
||||
* start udfd that serves udf function invocation under dnode startDnodeId
|
||||
* @param startDnodeId
|
||||
* @return
|
||||
*/
|
||||
int32_t udfStartUdfd(int32_t startDnodeId);
|
||||
/**
|
||||
* stop udfd
|
||||
* @return
|
||||
*/
|
||||
int32_t udfStopUdfd();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -129,6 +129,7 @@ typedef struct SDBVgInfo {
|
|||
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
|
||||
int64_t stateTs;
|
||||
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
|
||||
SArray* vgArray;
|
||||
} SDBVgInfo;
|
||||
|
||||
typedef struct SUseDbOutput {
|
||||
|
@ -238,6 +239,7 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t
|
|||
char* parseTagDatatoJson(void* p);
|
||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
||||
void freeVgInfo(SDBVgInfo* vgInfo);
|
||||
|
||||
extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen,
|
||||
void* (*mallocFp)(int64_t));
|
||||
|
@ -261,24 +263,22 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code))
|
||||
|
||||
#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || (_code) == TSDB_CODE_VND_STOPPED)
|
||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
|
||||
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) (false) // used later
|
||||
|
||||
#define NEED_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
||||
((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
|
||||
(_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \
|
||||
(_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_RPC_BROKEN_LINK || \
|
||||
(_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
||||
|
||||
#define NEED_CLIENT_RM_TBLMETA_REQ(_type) \
|
||||
((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \
|
||||
(_type) == TDMT_MND_DROP_STB)
|
||||
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_MNODE_NOT_FOUND || \
|
||||
SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || (_code) == TSDB_CODE_SYN_RESTORING || \
|
||||
#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \
|
||||
((_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
|
||||
SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \
|
||||
(_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING)
|
||||
|
||||
#define REQUEST_TOTAL_EXEC_TIMES 2
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct STdbState {
|
|||
TTB* pFillStateDb; // todo refactor
|
||||
TTB* pSessionStateDb;
|
||||
TTB* pParNameDb;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
} STdbState;
|
||||
|
||||
// incremental state storage
|
||||
|
|
|
@ -620,7 +620,7 @@ typedef struct SStreamMeta {
|
|||
SHashObj* pTasks;
|
||||
SHashObj* pRecoverStatus;
|
||||
void* ahandle;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
FTaskExpand* expandFunc;
|
||||
int32_t vgId;
|
||||
SRWLatch lock;
|
||||
|
|
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
#define SYNC_MAX_RETRY_BACKOFF 5
|
||||
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||
#define SYNC_HEART_TIMEOUT_MS 1000 * 8
|
||||
#define SYNC_HEART_TIMEOUT_MS 1000 * 15
|
||||
|
||||
#define SYNC_HEARTBEAT_SLOW_MS 1500
|
||||
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
|
||||
|
@ -138,8 +138,8 @@ typedef struct SSnapshotMeta {
|
|||
typedef struct SSyncFSM {
|
||||
void* data;
|
||||
|
||||
void (*FpCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
void (*FpPreCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
int32_t (*FpCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
int32_t (*FpPreCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
void (*FpRollBackCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta);
|
||||
|
||||
void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm);
|
||||
|
|
|
@ -88,6 +88,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
|
|||
int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count);
|
||||
int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset);
|
||||
int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count);
|
||||
int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset);
|
||||
void taosFprintfFile(TdFilePtr pFile, const char *format, ...);
|
||||
|
||||
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf);
|
||||
|
|
|
@ -40,61 +40,61 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
||||
// rpc
|
||||
// #define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) //2.x
|
||||
// #define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002) //2.x
|
||||
#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||
#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004)
|
||||
// #define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005) //2.x
|
||||
// #define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006) //2.x
|
||||
// #define TSDB_CODE_RPC_LAST_SESSION_NOT_FINI. TAOS_DEF_ERROR_CODE(0, 0x0007) //2.x
|
||||
// #define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008) //2.x
|
||||
// #define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009) //2.x
|
||||
// #define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A) //2.x
|
||||
// #define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) // 2.x
|
||||
// #define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002) // 2.x
|
||||
// #define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003) // 2.x
|
||||
// #define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004) // 2.x
|
||||
// #define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005) // 2.x
|
||||
// #define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006) // 2.x
|
||||
// #define TSDB_CODE_RPC_LAST_SESSION_NOT_FINI. TAOS_DEF_ERROR_CODE(0, 0x0007) // 2.x
|
||||
// #define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008) // 2.x
|
||||
// #define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009) // 2.x
|
||||
// #define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A) // 2.x
|
||||
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B)
|
||||
// #define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C) //2.x
|
||||
// #define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D) //2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E) //2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F) //2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010) //2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011) //2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012) //2.x
|
||||
#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013)
|
||||
// #define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) //2.x
|
||||
// #define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C) // 2.x
|
||||
// #define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D) // 2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E) // 2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F) // 2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010) // 2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011) // 2.x
|
||||
// #define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012) // 2.x
|
||||
#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013) //
|
||||
// #define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) // 2.x
|
||||
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015)
|
||||
// #define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016) //2.x
|
||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017)
|
||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018)
|
||||
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019)
|
||||
// #define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016) // 2.x
|
||||
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
|
||||
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
|
||||
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
|
||||
|
||||
//common & util
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100)
|
||||
#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0101)
|
||||
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
|
||||
// #define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0101) // 2.x
|
||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0102)
|
||||
// #define TSDB_CODE_COM_INVALID_CFG_MSG TAOS_DEF_ERROR_CODE(0, 0x0103) // 2.x
|
||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104)
|
||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105)
|
||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106)
|
||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107)
|
||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108)
|
||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109)
|
||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A)
|
||||
#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104) //
|
||||
#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105) // internal
|
||||
#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106) // internal
|
||||
#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107) // internal
|
||||
#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) // internal
|
||||
#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109) // internal
|
||||
#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A) // internal
|
||||
|
||||
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110)
|
||||
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111)
|
||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0112)
|
||||
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0113)
|
||||
#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0114)
|
||||
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0115)
|
||||
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110) //
|
||||
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111) // internal
|
||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0112) //
|
||||
// #define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0113)
|
||||
// #define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0114)
|
||||
#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0115) //
|
||||
#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0116) //
|
||||
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0117)
|
||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0118)
|
||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0119)
|
||||
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x011A)
|
||||
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x011B)
|
||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x011C)
|
||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x011D)
|
||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x011E)
|
||||
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x011F)
|
||||
#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0117) // internal
|
||||
#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0118) //
|
||||
#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0119) // internal
|
||||
#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x011A) // internal
|
||||
#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x011B) // internal
|
||||
#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x011C) // internal
|
||||
#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x011D) // internal
|
||||
#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x011E) // internal
|
||||
#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x011F) // internal
|
||||
|
||||
#define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0120)
|
||||
#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0121) //
|
||||
|
@ -126,11 +126,11 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_INVALID_DB_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0209)
|
||||
#define TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH TAOS_DEF_ERROR_CODE(0, 0x020A)
|
||||
#define TSDB_CODE_TSC_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x020B)
|
||||
#define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C)
|
||||
// #define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C) // 2.x
|
||||
#define TSDB_CODE_TSC_QUERY_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E)
|
||||
#define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F)
|
||||
#define TSDB_CODE_TSC_SORTED_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0210)
|
||||
#define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211)
|
||||
// #define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211) // 2.x
|
||||
#define TSDB_CODE_TSC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0212)
|
||||
#define TSDB_CODE_TSC_DISCONNECTED TAOS_DEF_ERROR_CODE(0, 0x0213)
|
||||
#define TSDB_CODE_TSC_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0214)
|
||||
|
@ -158,9 +158,17 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F)
|
||||
|
||||
// mnode-common
|
||||
// #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) // 2.x
|
||||
// #define TSDB_CODE_MND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0301) // 2.x
|
||||
// #define TSDB_CODE_MND_ACTION_NEED_REPROCESSEDTAOS_DEF_ERROR_CODE(0, 0x0302) // 2.x
|
||||
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0303)
|
||||
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304)
|
||||
// #define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0305)
|
||||
// #define TSDB_CODE_MND_INVALID_MSG_VERSION TAOS_DEF_ERROR_CODE(0, 0x0306) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0307) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0308) // 2.x
|
||||
// #define TSDB_CODE_MND_TOO_MANY_SHELL_CONNS TAOS_DEF_ERROR_CODE(0, 0x0309) // 2.x
|
||||
// #define TSDB_CODE_MND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x030A) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x030B)
|
||||
#define TSDB_CODE_MND_INVALID_QUERY_ID TAOS_DEF_ERROR_CODE(0, 0x030C)
|
||||
#define TSDB_CODE_MND_INVALID_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x030D)
|
||||
|
@ -174,7 +182,7 @@ int32_t* taosGetErrno();
|
|||
|
||||
// mnode-sdb
|
||||
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320)
|
||||
#define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // internal
|
||||
// #define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // 2.x
|
||||
#define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0322)
|
||||
#define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323)
|
||||
#define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325)
|
||||
|
@ -217,22 +225,31 @@ int32_t* taosGetErrno();
|
|||
|
||||
// mnode-stable-part1
|
||||
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
|
||||
// #define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) // 2.x
|
||||
#define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0362)
|
||||
// #define TSDB_CODE_MND_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0363) // 2.x
|
||||
#define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x0364)
|
||||
#define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x0365)
|
||||
// #define TSDB_CODE_MND_TOO_MANY_TIMESERIES TAOS_DEF_ERROR_CODE(0, 0x0366) // 2.x
|
||||
// #define TSDB_CODE_MND_NOT_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x0367) // 2.x
|
||||
// #define TSDB_CODE_MND_COL_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x0368) // 2.x
|
||||
#define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0369)
|
||||
#define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036A)
|
||||
#define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x036B)
|
||||
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036C)
|
||||
// #define TSDB_CODE_MND_INVALID_STABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x036D) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x036E)
|
||||
#define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F)
|
||||
|
||||
// mnode-func
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0370)
|
||||
// #define TSDB_CODE_MND_INVALID_FUNC_LEN TAOS_DEF_ERROR_CODE(0, 0x0371) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0372)
|
||||
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0373)
|
||||
#define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0374)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0375)
|
||||
// #define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) // 2.x
|
||||
// #define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) // 2.x
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0378)
|
||||
#define TSDB_CODE_MND_INVALID_FUNC_RETRIEVE TAOS_DEF_ERROR_CODE(0, 0x0379)
|
||||
|
||||
|
@ -381,6 +398,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
|
||||
#define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
|
||||
#define TSDB_CODE_VND_STOPPED TAOS_DEF_ERROR_CODE(0, 0x0529)
|
||||
#define TSDB_CODE_VND_DUP_REQUEST TAOS_DEF_ERROR_CODE(0, 0x0530)
|
||||
|
||||
// tsdb
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
|
||||
|
@ -390,8 +408,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604)
|
||||
#define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605)
|
||||
#define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607)
|
||||
#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608)
|
||||
#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609)
|
||||
// #define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) // 2.x
|
||||
// #define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) // 2.x
|
||||
#define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A)
|
||||
#define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B)
|
||||
#define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C)
|
||||
|
@ -405,6 +423,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
|
||||
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
|
||||
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
|
||||
// #define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) // 2.x
|
||||
#define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618)
|
||||
#define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619)
|
||||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||
|
@ -415,8 +434,9 @@ int32_t* taosGetErrno();
|
|||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
#define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701)
|
||||
#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703)
|
||||
#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704)
|
||||
// #define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702) // 2.x
|
||||
// #define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) // 2.x
|
||||
// #define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) // 2.x
|
||||
#define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705)
|
||||
#define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706)
|
||||
#define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707)
|
||||
|
@ -428,6 +448,8 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070D)
|
||||
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070E)
|
||||
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F)
|
||||
// #define TSDB_CODE_QRY_INVALID_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0710) // 2.x
|
||||
// #define TSDB_CODE_QRY_RESULT_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0711) // 2.x
|
||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0720)
|
||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0721)
|
||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0722)
|
||||
|
@ -463,7 +485,17 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D)
|
||||
|
||||
// sync
|
||||
// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x
|
||||
// #define TSDB_CODE_SYN_NOT_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0901) // 2.x
|
||||
// #define TSDB_CODE_SYN_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0902) // 2.x
|
||||
#define TSDB_CODE_SYN_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0903)
|
||||
// #define TSDB_CODE_SYN_TOO_MANY_FWDINFO TAOS_DEF_ERROR_CODE(0, 0x0904) // 2.x
|
||||
// #define TSDB_CODE_SYN_MISMATCHED_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0905) // 2.x
|
||||
// #define TSDB_CODE_SYN_MISMATCHED_CLUSTERID TAOS_DEF_ERROR_CODE(0, 0x0906) // 2.x
|
||||
// #define TSDB_CODE_SYN_MISMATCHED_SIGNATURE TAOS_DEF_ERROR_CODE(0, 0x0907) // 2.x
|
||||
// #define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908) // 2.x
|
||||
// #define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909) // 2.x
|
||||
// #define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A) // 2.x
|
||||
#define TSDB_CODE_SYN_IS_LEADER TAOS_DEF_ERROR_CODE(0, 0x090B)
|
||||
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C)
|
||||
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D)
|
||||
|
@ -481,7 +513,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01)
|
||||
#define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03)
|
||||
#define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04)
|
||||
#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||
// #define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05)
|
||||
#define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06)
|
||||
#define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07)
|
||||
#define TSDB_CODE_TQ_META_NO_SUCH_KEY TAOS_DEF_ERROR_CODE(0, 0x0A08)
|
||||
|
@ -492,16 +524,17 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TQ_NO_COMMITTED_OFFSET TAOS_DEF_ERROR_CODE(0, 0x0A0D)
|
||||
|
||||
// wal
|
||||
#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000)
|
||||
// #define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) // 2.x
|
||||
#define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001)
|
||||
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002)
|
||||
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
|
||||
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
|
||||
// #define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) // 2.x
|
||||
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
|
||||
#define TSDB_CODE_WAL_CHKSUM_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x1006)
|
||||
#define TSDB_CODE_WAL_LOG_INCOMPLETE TAOS_DEF_ERROR_CODE(0, 0x1007)
|
||||
|
||||
// tfs
|
||||
// #define TSDB_CODE_FS_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x2200) // 2.x
|
||||
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
|
||||
#define TSDB_CODE_FS_TOO_MANY_MOUNT TAOS_DEF_ERROR_CODE(0, 0x2202)
|
||||
#define TSDB_CODE_FS_DUP_PRIMARY TAOS_DEF_ERROR_CODE(0, 0x2203)
|
||||
|
@ -510,7 +543,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_FS_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2206)
|
||||
#define TSDB_CODE_FS_INVLD_LEVEL TAOS_DEF_ERROR_CODE(0, 0x2207)
|
||||
#define TSDB_CODE_FS_NO_VALID_DISK TAOS_DEF_ERROR_CODE(0, 0x2208)
|
||||
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x220F)
|
||||
// #define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x220F) // 2.x
|
||||
|
||||
// catalog
|
||||
#define TSDB_CODE_CTG_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2400)
|
||||
|
|
|
@ -171,9 +171,9 @@ typedef struct SReqResultInfo {
|
|||
char** convertBuf;
|
||||
TAOS_ROW row;
|
||||
SResultColumn* pCol;
|
||||
uint32_t numOfRows;
|
||||
uint64_t numOfRows; // from int32_t change to int64_t
|
||||
uint64_t totalRows;
|
||||
uint32_t current;
|
||||
uint64_t current;
|
||||
bool localResultFetched;
|
||||
bool completed;
|
||||
int32_t precision;
|
||||
|
|
|
@ -244,14 +244,14 @@ void destroyTscObj(void *pObj) {
|
|||
void *createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo) {
|
||||
STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||
if (NULL == pObj) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == pObj->pRequests) {
|
||||
taosMemoryFree(pObj);
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, ri
|
|||
void *createRequest(uint64_t connId, int32_t type, int64_t reqid) {
|
||||
SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||
if (NULL == pRequest) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
|||
} else {
|
||||
SDBVgInfo *vgInfo = taosMemoryCalloc(1, sizeof(SDBVgInfo));
|
||||
if (NULL == vgInfo) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
|||
if (NULL == vgInfo->vgHash) {
|
||||
taosMemoryFree(vgInfo);
|
||||
tscError("hash init[%d] failed", rsp->vgNum);
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
|
|||
tscError("hash push failed, errno:%d", errno);
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
taosMemoryFree(vgInfo);
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
|
|||
desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc));
|
||||
if (NULL == desc.subDesc) {
|
||||
releaseRequest(*rid);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc);
|
||||
|
@ -394,14 +394,14 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
|||
STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid);
|
||||
if (NULL == pTscObj) {
|
||||
tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic));
|
||||
if (NULL == hbBasic) {
|
||||
tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic));
|
||||
releaseTscObj(connKey->tscRid);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
hbBasic->connId = pTscObj->connId;
|
||||
|
@ -419,7 +419,7 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
|
|||
tscWarn("taosArrayInit %d queryDesc failed", numOfQueries);
|
||||
releaseTscObj(connKey->tscRid);
|
||||
taosMemoryFree(hbBasic);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = hbBuildQueryDesc(hbBasic, pTscObj);
|
||||
|
@ -613,7 +613,7 @@ static FORCE_INLINE void hbMgrInitHandle() {
|
|||
SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||
SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq));
|
||||
if (pBatchReq == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
int32_t connKeyCnt = atomic_load_32(&pAppHbMgr->connKeyCnt);
|
||||
|
@ -737,7 +737,7 @@ static void *hbThreadFunc(void *param) {
|
|||
int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq);
|
||||
void *buf = taosMemoryMalloc(tlen);
|
||||
if (buf == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
taosArrayPush(mgr, &pAppHbMgr);
|
||||
|
@ -748,7 +748,7 @@ static void *hbThreadFunc(void *param) {
|
|||
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
|
||||
if (pInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeClientHbBatchReq(pReq);
|
||||
// hbClearReqInfo(pAppHbMgr);
|
||||
taosMemoryFree(buf);
|
||||
|
|
|
@ -166,7 +166,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
tscError("0x%" PRIx64 " failed to prepare sql string buffer, %s", (*pRequest)->self, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
strntolower((*pRequest)->sqlstr, sql, (int32_t)sqlLen);
|
||||
|
@ -179,7 +179,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
if (pParam == NULL) {
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
tsem_init(&pParam->sem, 0, 0);
|
||||
|
@ -198,7 +198,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
taosMemoryFree(param);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
(*pRequest)->allocatorRefId = -1;
|
||||
|
@ -209,7 +209,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
|
|||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||
pRequest->requestId);
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
|
|||
}
|
||||
default:
|
||||
tscError("unknown query policy: %d", tsQueryPolicy);
|
||||
return TSDB_CODE_TSC_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
taosArrayDestroy(pDbVgList);
|
||||
|
@ -670,7 +670,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
|
|||
}
|
||||
default:
|
||||
tscError("unknown query policy: %d", tsQueryPolicy);
|
||||
return TSDB_CODE_TSC_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -1136,7 +1136,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) {
|
|||
int32_t tblNum = taosArrayGetSize(pRequest->tableList);
|
||||
|
||||
if (dbNum <= 0 && tblNum <= 0) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
|
@ -1231,7 +1231,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
|||
SAppInstInfo* pAppInfo, int connType) {
|
||||
STscObj* pTscObj = createTscObj(user, auth, db, connType, pAppInfo);
|
||||
if (NULL == pTscObj) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return pTscObj;
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
|
|||
static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
|
||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (pMsgSendInfo == NULL) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1527,7 +1527,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pResInfo->numOfRows, pResInfo->totalRows, pResInfo->completed, pRequest->requestId);
|
||||
|
||||
STscObj* pTscObj = pRequest->pTscObj;
|
||||
|
@ -1941,7 +1941,7 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
|
|||
|
||||
pResultInfo->pRspMsg = (const char*)pRsp;
|
||||
pResultInfo->pData = (void*)pRsp->data;
|
||||
pResultInfo->numOfRows = htonl(pRsp->numOfRows);
|
||||
pResultInfo->numOfRows = htobe64(pRsp->numOfRows);
|
||||
pResultInfo->current = 0;
|
||||
pResultInfo->completed = (pRsp->completed == 1);
|
||||
pResultInfo->payloadLen = htonl(pRsp->compLen);
|
||||
|
|
|
@ -146,7 +146,6 @@ void taos_close(TAOS *taos) {
|
|||
|
||||
int taos_errno(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -154,12 +153,11 @@ int taos_errno(TAOS_RES *res) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return ((SRequestObj *)res)->code == TSDB_CODE_RPC_REDIRECT ? TSDB_CODE_QRY_NOT_READY : ((SRequestObj *)res)->code;
|
||||
return ((SRequestObj *)res)->code;
|
||||
}
|
||||
|
||||
const char *taos_errstr(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ_META(res)) {
|
||||
if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY;
|
||||
return (const char *)tstrerror(terrno);
|
||||
}
|
||||
|
||||
|
@ -171,8 +169,7 @@ const char *taos_errstr(TAOS_RES *res) {
|
|||
if (NULL != pRequest->msgBuf && (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)) {
|
||||
return pRequest->msgBuf;
|
||||
} else {
|
||||
return pRequest->code == TSDB_CODE_RPC_REDIRECT ? (const char *)tstrerror(TSDB_CODE_QRY_NOT_READY)
|
||||
: (const char *)tstrerror(pRequest->code);
|
||||
return (const char *)tstrerror(pRequest->code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,11 +435,23 @@ const char *taos_data_type(int type) {
|
|||
|
||||
const char *taos_get_client_info() { return version; }
|
||||
|
||||
// return int32_t
|
||||
int taos_affected_rows(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||
return (int)pResInfo->numOfRows;
|
||||
}
|
||||
|
||||
// return int64_t
|
||||
int64_t taos_affected_rows64(TAOS_RES *res) {
|
||||
if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SRequestObj *pRequest = (SRequestObj *)res;
|
||||
SReqResultInfo *pResInfo = &pRequest->body.resInfo;
|
||||
return pResInfo->numOfRows;
|
||||
|
@ -959,7 +968,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
|
|||
tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed,
|
||||
pRequest->requestId);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
|
||||
/*assert(connectRsp.epSet.numOfEps > 0);*/
|
||||
if (connectRsp.epSet.numOfEps == 0) {
|
||||
setErrno(pRequest, TSDB_CODE_MND_APP_ERROR);
|
||||
setErrno(pRequest, TSDB_CODE_APP_ERROR);
|
||||
tsem_post(&pRequest->body.rspSem);
|
||||
goto End;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
|||
(*pRsp)->precision = 0;
|
||||
(*pRsp)->compressed = 0;
|
||||
(*pRsp)->compLen = 0;
|
||||
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
||||
(*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
|
||||
|
||||
int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS);
|
||||
|
|
|
@ -1388,7 +1388,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
|
|||
|
||||
SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vgData;
|
||||
|
@ -1579,7 +1579,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
|
||||
SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vgData;
|
||||
|
@ -1726,7 +1726,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen;
|
||||
void* tmp = taosMemoryRealloc(vgData.data, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
|
@ -1737,7 +1737,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
int32_t totalLen = sizeof(SSubmitReq) + submitLen;
|
||||
void* tmp = taosMemoryCalloc(1, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
|
@ -1840,7 +1840,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
while (vData) {
|
||||
SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vData->vg;
|
||||
|
@ -2029,7 +2029,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen;
|
||||
void* tmp = taosMemoryRealloc(vgData.data, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
|
@ -2040,7 +2040,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
int32_t totalLen = sizeof(SSubmitReq) + submitLen;
|
||||
void* tmp = taosMemoryCalloc(1, totalLen);
|
||||
if (tmp == NULL) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
vgData.data = tmp;
|
||||
|
@ -2146,7 +2146,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
while (vData) {
|
||||
SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks));
|
||||
if (NULL == dst) {
|
||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
dst->vg = vData->vg;
|
||||
|
|
|
@ -1417,7 +1417,7 @@ static int32_t smlDealCols(SSmlTableInfo *oneTable, bool dataFormat, SArray *col
|
|||
SHashObj *kvHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK);
|
||||
if (!kvHash) {
|
||||
uError("SML:smlDealCols failed to allocate memory");
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (size_t i = 0; i < taosArrayGetSize(cols); i++) {
|
||||
SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i);
|
||||
|
@ -2092,7 +2092,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int l
|
|||
cols = taosArrayInit(16, POINTER_BYTES);
|
||||
if (cols == NULL) {
|
||||
uError("SML:0x%" PRIx64 " smlParseInfluxLine failed to allocate memory", info->id);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
} else { // if dataFormat is false, cols do not need to save data, there is another new memory to save data
|
||||
cols = info->colsContainer;
|
||||
|
@ -2121,7 +2121,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int l
|
|||
if (!tinfo) {
|
||||
smlDestroyCols(cols);
|
||||
if (info->dataFormat) taosArrayDestroy(cols);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosHashPut(info->childTables, elements.measure, elements.measureTagsLen, &tinfo, POINTER_BYTES);
|
||||
oneTable = &tinfo;
|
||||
|
@ -2192,13 +2192,13 @@ static int32_t smlParseTelnetLine(SSmlHandle *info, void *data, const int len) {
|
|||
int ret = TSDB_CODE_SUCCESS;
|
||||
SSmlTableInfo *tinfo = smlBuildTableInfo();
|
||||
if (!tinfo) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SArray *cols = taosArrayInit(16, POINTER_BYTES);
|
||||
if (cols == NULL) {
|
||||
uError("SML:0x%" PRIx64 " smlParseTelnetLine failed to allocate memory", info->id);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||
|
|
|
@ -83,7 +83,7 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
code = TSDB_CODE_TSC_APP_ERROR;
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) {
|
|||
pRes->fields = taosMemoryMalloc(size);
|
||||
pRes->userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pRes->fields || NULL == pRes->userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size);
|
||||
memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size);
|
||||
|
@ -136,7 +136,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.fields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size);
|
||||
if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) {
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY);
|
||||
STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size);
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) {
|
|||
tscError("table [%s, %" PRIx64 ", %" PRIx64 "] found in exec blockHash, but not in sql blockHash",
|
||||
pStmt->bInfo.tbFName, uid, cacheUid);
|
||||
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
pStmt->bInfo.needParse = false;
|
||||
|
@ -512,7 +512,7 @@ int32_t stmtResetStmt(STscStmt* pStmt) {
|
|||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
STMT_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
|
@ -527,13 +527,13 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid) {
|
|||
|
||||
pStmt = taosMemoryCalloc(1, sizeof(STscStmt));
|
||||
if (NULL == pStmt) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == pStmt->sql.pTableCache) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pStmt);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
|||
(STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
tscDebug("start to bind stmt tag values");
|
||||
|
@ -641,7 +641,7 @@ int stmtFetchTagFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields
|
|||
(STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
STMT_ERR_RET(qBuildStmtTagFields(*pDataBlock, pStmt->bInfo.boundTags, fieldNum, fields));
|
||||
|
@ -659,7 +659,7 @@ int stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields
|
|||
(STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields));
|
||||
|
@ -733,7 +733,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
(STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName));
|
||||
if (NULL == pDataBlock) {
|
||||
tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (colIdx < 0) {
|
||||
|
@ -745,7 +745,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
|
|||
} else {
|
||||
if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) {
|
||||
tscError("bind column index not in sequence");
|
||||
STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
STMT_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
pStmt->bInfo.sBindLastIdx = colIdx;
|
||||
|
@ -897,7 +897,7 @@ _return:
|
|||
if (TSDB_CODE_SUCCESS == code && autoCreateTbl) {
|
||||
if (NULL == pRsp) {
|
||||
tscError("no submit resp got for auto create table");
|
||||
code = TSDB_CODE_TSC_APP_ERROR;
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
} else {
|
||||
code = stmtUpdateTableUid(pStmt, pRsp);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "tlog.h"
|
||||
#include "tname.h"
|
||||
|
||||
#define MALLOC_ALIGN_BYTES 32
|
||||
#define MALLOC_ALIGN_BYTES 256
|
||||
|
||||
int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) {
|
||||
ASSERT(pColumnInfoData != NULL);
|
||||
|
@ -1137,14 +1137,15 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
|
|||
}
|
||||
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock) {
|
||||
blockDataEmpty(pDataBlock);
|
||||
SDataBlockInfo* pInfo = &pDataBlock->info;
|
||||
|
||||
pInfo->rows = 0;
|
||||
pInfo->id.uid = 0;
|
||||
pInfo->id.groupId = 0;
|
||||
pInfo->window.ekey = 0;
|
||||
pInfo->window.skey = 0;
|
||||
}
|
||||
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock) {
|
||||
SDataBlockInfo* pInfo = &pDataBlock->info;
|
||||
ASSERT(pInfo->rows <= pDataBlock->info.capacity);
|
||||
if (pInfo->capacity == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -1154,6 +1155,10 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
|
|||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
colInfoDataCleanup(p, pInfo->capacity);
|
||||
}
|
||||
|
||||
pInfo->rows = 0;
|
||||
pInfo->window.ekey = 0;
|
||||
pInfo->window.skey = 0;
|
||||
}
|
||||
|
||||
// todo temporarily disable it
|
||||
|
@ -1186,7 +1191,6 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
|||
int32_t oldLen = BitmapLen(existedRows);
|
||||
pColumn->nullbitmap = tmp;
|
||||
memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen);
|
||||
|
||||
ASSERT(pColumn->info.bytes);
|
||||
|
||||
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
|
||||
|
@ -1202,6 +1206,12 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
|
|||
}
|
||||
|
||||
pColumn->pData = tmp;
|
||||
|
||||
// todo remove it soon
|
||||
#if defined LINUX
|
||||
ASSERT((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) == 0x0);
|
||||
#endif
|
||||
|
||||
if (clearPayload) {
|
||||
memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows));
|
||||
}
|
||||
|
@ -1249,6 +1259,25 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows) {
|
||||
int32_t code = 0;
|
||||
if (numOfRows == 0 || numOfRows <= pDataBlock->info.capacity) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i);
|
||||
code = doEnsureCapacity(p, &pDataBlock->info, numOfRows, false);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
pDataBlock->info.capacity = numOfRows;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void blockDataFreeRes(SSDataBlock* pBlock) {
|
||||
int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
|
@ -1621,6 +1650,8 @@ static int32_t colDataMoveVarData(SColumnInfoData* pColInfoData, size_t start, s
|
|||
static void colDataTrimFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_t total) {
|
||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, n, total);
|
||||
|
||||
// clear the offset value of the unused entries.
|
||||
memset(&pColInfoData->varmeta.offset[total - n], 0, n);
|
||||
} else {
|
||||
int32_t bytes = pColInfoData->info.bytes;
|
||||
|
@ -1635,7 +1666,7 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n) {
|
|||
}
|
||||
|
||||
if (pBlock->info.rows <= n) {
|
||||
blockDataCleanup(pBlock);
|
||||
blockDataEmpty(pBlock);
|
||||
} else {
|
||||
size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
|
@ -1652,12 +1683,22 @@ static void colDataKeepFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_
|
|||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||
pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, 0, n);
|
||||
memset(&pColInfoData->varmeta.offset[n], 0, total - n);
|
||||
} else { // reset the bitmap value
|
||||
/*int32_t stopIndex = BitmapLen(n) * 8;
|
||||
for(int32_t i = n; i < stopIndex; ++i) {
|
||||
colDataClearNull_f(pColInfoData->nullbitmap, i);
|
||||
}
|
||||
|
||||
int32_t remain = BitmapLen(total) - BitmapLen(n);
|
||||
if (remain > 0) {
|
||||
memset(pColInfoData->nullbitmap+BitmapLen(n), 0, remain);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n) {
|
||||
if (n == 0) {
|
||||
blockDataCleanup(pBlock);
|
||||
blockDataEmpty(pBlock);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) {
|
|||
|
||||
SRowIter *pIter = taosMemoryCalloc(1, sizeof(*pIter));
|
||||
if (pIter == NULL) {
|
||||
code = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,11 @@ int32_t tsNumOfQnodeFetchThreads = 1;
|
|||
int32_t tsNumOfSnodeStreamThreads = 4;
|
||||
int32_t tsNumOfSnodeWriteThreads = 1;
|
||||
|
||||
// sync raft
|
||||
int32_t tsElectInterval = 25 * 1000;
|
||||
int32_t tsHeartbeatInterval = 1000;
|
||||
int32_t tsHeartbeatTimeout = 20 * 1000;
|
||||
|
||||
// monitor
|
||||
bool tsEnableMonitor = true;
|
||||
int32_t tsMonitorInterval = 30;
|
||||
|
@ -74,8 +79,8 @@ char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null";
|
|||
char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value.
|
||||
// If set to empty system will generate table name using MD5 hash.
|
||||
// true means that the name and order of cols in each line are the same(only for influx protocol)
|
||||
bool tsSmlDataFormat = false;
|
||||
int32_t tsSmlBatchSize = 10000;
|
||||
bool tsSmlDataFormat = false;
|
||||
int32_t tsSmlBatchSize = 10000;
|
||||
|
||||
// query
|
||||
int32_t tsQueryPolicy = 1;
|
||||
|
@ -198,9 +203,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
|
|||
int32_t taosSetTfsCfg(SConfig *pCfg);
|
||||
#endif
|
||||
|
||||
struct SConfig *taosGetCfg() {
|
||||
return tsCfg;
|
||||
}
|
||||
struct SConfig *taosGetCfg() { return tsCfg; }
|
||||
|
||||
static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile,
|
||||
char *apolloUrl) {
|
||||
|
@ -423,6 +426,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, 0) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, 0) != 0) return -1;
|
||||
|
@ -728,6 +735,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN);
|
||||
tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32;
|
||||
|
||||
tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32;
|
||||
tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32;
|
||||
tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32;
|
||||
|
||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||
tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32;
|
||||
tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32;
|
||||
|
@ -737,6 +748,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64;
|
||||
|
||||
tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32;
|
||||
tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32;
|
||||
tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32;
|
||||
|
||||
tsStartUdfd = cfgGetItem(pCfg, "udf")->bval;
|
||||
tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs));
|
||||
tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath));
|
||||
|
|
|
@ -61,7 +61,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
pMsg->info.rsp = NULL;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_RPC_REDIRECT) {
|
||||
if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING) {
|
||||
mndPostProcessQueryMsg(pMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,23 +33,6 @@ static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) {
|
||||
pMsg->info.hasEpSet = 1;
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info, .msgType = pMsg->msgType};
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet);
|
||||
|
||||
rsp.pCont = rpcMallocCont(contLen);
|
||||
if (rsp.pCont == NULL) {
|
||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
tSerializeSEpSet(rsp.pCont, contLen, pNewEpSet);
|
||||
rsp.contLen = contLen;
|
||||
}
|
||||
dmSendRsp(&rsp);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
}
|
||||
|
||||
int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
|
||||
|
@ -243,9 +226,9 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { rpcRegisterBrokenLin
|
|||
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcReleaseHandle(pHandle, type); }
|
||||
|
||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_RPC_BROKEN_LINK ||
|
||||
code == TSDB_CODE_VND_STOPPED || code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED ||
|
||||
code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH ||
|
||||
msgType == TDMT_SCH_MERGE_FETCH) {
|
||||
return false;
|
||||
|
@ -334,7 +317,6 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) {
|
|||
.clientRpc = pDnode->trans.clientRpc,
|
||||
.sendReqFp = dmSendReq,
|
||||
.sendRspFp = dmSendRsp,
|
||||
.sendRedirectRspFp = dmSendRedirectRsp,
|
||||
.registerBrokenLinkArgFp = dmRegisterBrokenLinkArg,
|
||||
.releaseHandleFp = dmReleaseHandle,
|
||||
.reportStartupFp = dmReportStartup,
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "sync.h"
|
||||
#include "wal.h"
|
||||
|
||||
#include "libs/function/function.h"
|
||||
#include "libs/function/tudf.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -220,7 +220,7 @@ static int32_t mndProcessCreateAcctReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ static int32_t mndProcessAlterAcctReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ static int32_t mndProcessDropAcctReq(SRpcMsg *pReq) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||
mError("failed to process create acct request since %s", terrstr());
|
||||
return -1;
|
||||
}
|
|
@ -542,7 +542,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
|
|||
}
|
||||
default:
|
||||
mError("invalid kv key:%d", kv->key);
|
||||
hbRsp.status = TSDB_CODE_MND_APP_ERROR;
|
||||
hbRsp.status = TSDB_CODE_APP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ static int32_t mndSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
void mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SMnode *pMnode = pFsm->data;
|
||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||
SSdbRaw *pRaw = pMsg->pCont;
|
||||
|
@ -114,12 +114,15 @@ void mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *p
|
|||
mError("trans:%d, not found while execute in mnode since %s", transId, terrstr());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
||||
int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
int32_t code = mndProcessWriteMsg(pFsm, pMsg, pMeta);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
pMsg->pCont = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) {
|
||||
|
|
|
@ -945,7 +945,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
|||
code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL;
|
||||
}
|
||||
if (i != 0 && code == 0) {
|
||||
code = TSDB_CODE_RPC_REDIRECT;
|
||||
code = TSDB_CODE_MNODE_NOT_FOUND;
|
||||
}
|
||||
mInfo("trans:%d, client:%d send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code, mndTransStr(pTrans->stage),
|
||||
pInfo->ahandle);
|
||||
|
@ -1042,8 +1042,8 @@ static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pA
|
|||
pAction->rawWritten = 0;
|
||||
pAction->msgSent = 0;
|
||||
pAction->msgReceived = 0;
|
||||
if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR ||
|
||||
pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) {
|
||||
if (pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR ||
|
||||
pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) {
|
||||
pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps;
|
||||
mInfo("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage),
|
||||
pAction->id, pAction->epSet.inUse);
|
||||
|
|
|
@ -276,7 +276,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
|
|||
}
|
||||
|
||||
if (createReq.selfIndex == -1) {
|
||||
terrno = TSDB_CODE_MND_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
|
|||
}
|
||||
|
||||
if (alterReq.selfIndex == -1) {
|
||||
terrno = TSDB_CODE_MND_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(MndTestAcct, 01_Create_Acct) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 02_Alter_Acct) {
|
||||
|
@ -42,7 +42,7 @@ TEST_F(MndTestAcct, 02_Alter_Acct) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
TEST_F(MndTestAcct, 03_Drop_Acct) {
|
||||
|
@ -52,5 +52,5 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
|
|||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED);
|
||||
ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT);
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
code = TSDB_CODE_SDB_APP_ERROR;
|
||||
code = TSDB_CODE_APP_ERROR;
|
||||
taosHashCancelIterate(hash, ppRow);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ static SHashObj *sdbGetHash(SSdb *pSdb, int32_t type) {
|
|||
|
||||
SHashObj *hash = pSdb->hashObjs[type];
|
||||
if (hash == NULL) {
|
||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
|
|||
terrno = TSDB_CODE_SDB_OBJ_DROPPING;
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_SDB_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,20 +169,19 @@ typedef struct STsdbReader STsdbReader;
|
|||
|
||||
int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num);
|
||||
int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables,
|
||||
STsdbReader **ppReader, const char *idstr);
|
||||
SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr);
|
||||
|
||||
void tsdbReaderClose(STsdbReader *pReader);
|
||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||
bool tsdbTableNextDataBlock(STsdbReader *pReader, uint64_t uid);
|
||||
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
||||
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
|
||||
void *tsdbGetIdx(SMeta *pMeta);
|
||||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||
void tsdbReaderClose(STsdbReader *pReader);
|
||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||
void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow);
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockSMA, bool *allHave);
|
||||
SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
|
||||
void *tsdbGetIdx(SMeta *pMeta);
|
||||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||
|
||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
uint64_t suid, void **pReader);
|
||||
|
|
|
@ -70,7 +70,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid);
|
|||
int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo);
|
||||
int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid);
|
||||
int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
|
||||
void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta);
|
||||
void metaUpdateStbStats(SMeta* pMeta, int64_t uid, int64_t delta);
|
||||
int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle);
|
||||
|
||||
struct SMeta {
|
||||
|
@ -79,7 +79,7 @@ struct SMeta {
|
|||
char* path;
|
||||
SVnode* pVnode;
|
||||
TDB* pEnv;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
TTB* pTbDb;
|
||||
TTB* pSkmDb;
|
||||
TTB* pUidIdx;
|
||||
|
|
|
@ -77,7 +77,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
|||
|
||||
// vnodeQuery.c
|
||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||
void vnodeQueryPreClose(SVnode *pVnode);
|
||||
void vnodeQueryPreClose(SVnode* pVnode);
|
||||
void vnodeQueryClose(SVnode* pVnode);
|
||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
|
@ -86,7 +86,6 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
|||
// vnodeCommit.c
|
||||
int32_t vnodeBegin(SVnode* pVnode);
|
||||
int32_t vnodeShouldCommit(SVnode* pVnode);
|
||||
int32_t vnodeCommit(SVnode* pVnode);
|
||||
void vnodeRollback(SVnode* pVnode);
|
||||
int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg);
|
||||
int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo);
|
||||
|
@ -100,7 +99,7 @@ int32_t vnodeSyncOpen(SVnode* pVnode, char* path);
|
|||
int32_t vnodeSyncStart(SVnode* pVnode);
|
||||
void vnodeSyncPreClose(SVnode* pVnode);
|
||||
void vnodeSyncClose(SVnode* pVnode);
|
||||
void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg, int32_t code);
|
||||
bool vnodeIsLeader(SVnode* pVnode);
|
||||
bool vnodeIsRoleLeader(SVnode* pVnode);
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef struct SStreamStateWriter SStreamStateWriter;
|
|||
typedef struct SRSmaSnapReader SRSmaSnapReader;
|
||||
typedef struct SRSmaSnapWriter SRSmaSnapWriter;
|
||||
typedef struct SSnapDataHdr SSnapDataHdr;
|
||||
typedef struct SCommitInfo SCommitInfo;
|
||||
|
||||
#define VNODE_META_DIR "meta"
|
||||
#define VNODE_TSDB_DIR "tsdb"
|
||||
|
@ -100,8 +101,9 @@ typedef struct STbUidStore STbUidStore;
|
|||
int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
|
||||
int metaClose(SMeta* pMeta);
|
||||
int metaBegin(SMeta* pMeta, int8_t fromSys);
|
||||
int metaCommit(SMeta* pMeta);
|
||||
int metaFinishCommit(SMeta* pMeta);
|
||||
TXN* metaGetTxn(SMeta* pMeta);
|
||||
int metaCommit(SMeta* pMeta, TXN* txn);
|
||||
int metaFinishCommit(SMeta* pMeta, TXN* txn);
|
||||
int metaPrepareAsyncCommit(SMeta* pMeta);
|
||||
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
|
||||
|
@ -146,7 +148,8 @@ int32_t metaGetInfo(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo, SMetaReader* pR
|
|||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback);
|
||||
int tsdbClose(STsdb** pTsdb);
|
||||
int32_t tsdbBegin(STsdb* pTsdb);
|
||||
int32_t tsdbCommit(STsdb* pTsdb);
|
||||
int32_t tsdbPrepareCommit(STsdb* pTsdb);
|
||||
int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo);
|
||||
int32_t tsdbFinishCommit(STsdb* pTsdb);
|
||||
int32_t tsdbRollbackCommit(STsdb* pTsdb);
|
||||
int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now);
|
||||
|
@ -203,8 +206,8 @@ int32_t smaBegin(SSma* pSma);
|
|||
int32_t smaSyncPreCommit(SSma* pSma);
|
||||
int32_t smaSyncCommit(SSma* pSma);
|
||||
int32_t smaSyncPostCommit(SSma* pSma);
|
||||
int32_t smaPreCommit(SSma* pSma);
|
||||
int32_t smaCommit(SSma* pSma);
|
||||
int32_t smaPrepareAsyncCommit(SSma* pSma);
|
||||
int32_t smaCommit(SSma* pSma, SCommitInfo* pInfo);
|
||||
int32_t smaFinishCommit(SSma* pSma);
|
||||
int32_t smaPostCommit(SSma* pSma);
|
||||
int32_t smaDoRetention(SSma* pSma, int64_t now);
|
||||
|
@ -406,6 +409,12 @@ struct SSnapDataHdr {
|
|||
uint8_t data[];
|
||||
};
|
||||
|
||||
struct SCommitInfo {
|
||||
SVnodeInfo info;
|
||||
SVnode* pVnode;
|
||||
TXN* txn;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,12 +20,19 @@ static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVB
|
|||
|
||||
// begin a meta txn
|
||||
int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
||||
void *(*xMalloc)(void *, size_t);
|
||||
void (*xFree)(void *, void *);
|
||||
void *xArg = NULL;
|
||||
|
||||
if (fromSys) {
|
||||
tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||
xMalloc = tdbDefaultMalloc;
|
||||
xFree = tdbDefaultFree;
|
||||
} else {
|
||||
tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
|
||||
xMalloc = metaMalloc;
|
||||
xFree = metaFree;
|
||||
xArg = pMeta->pVnode->inUse;
|
||||
}
|
||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn) < 0) {
|
||||
if (tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -33,9 +40,10 @@ int metaBegin(SMeta *pMeta, int8_t fromSys) {
|
|||
}
|
||||
|
||||
// commit the meta txn
|
||||
int metaCommit(SMeta *pMeta) { return tdbCommit(pMeta->pEnv, &pMeta->txn); }
|
||||
int metaFinishCommit(SMeta *pMeta) { return tdbPostCommit(pMeta->pEnv, &pMeta->txn); }
|
||||
int metaPrepareAsyncCommit(SMeta *pMeta) { return tdbPrepareAsyncCommit(pMeta->pEnv, &pMeta->txn); }
|
||||
TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; }
|
||||
int metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); }
|
||||
int metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); }
|
||||
int metaPrepareAsyncCommit(SMeta *pMeta) { return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn); }
|
||||
|
||||
// abort the meta txn
|
||||
int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, &pMeta->txn); }
|
||||
int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, pMeta->txn); }
|
||||
|
|
|
@ -117,7 +117,7 @@ static int metaSaveSmaToDB(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
tEncoderClear(&coder);
|
||||
|
||||
// write to table.db
|
||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -131,17 +131,17 @@ _err:
|
|||
|
||||
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
SUidIdxVal uidIdxVal = {.suid = pME->smaEntry.tsma->indexUid, .version = pME->version, .skmVer = 0};
|
||||
return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateSmaIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
SSmaIdxKey smaIdxKey = {.uid = pME->smaEntry.tsma->tableUid, .smaUid = pME->smaEntry.tsma->indexUid};
|
||||
|
||||
return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaHandleSmaEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
|
|
|
@ -163,9 +163,9 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
|
|||
if (rollback) {
|
||||
ASSERT(0);
|
||||
} else {
|
||||
code = metaCommit(pWriter->pMeta);
|
||||
code = metaCommit(pWriter->pMeta, pWriter->pMeta->txn);
|
||||
if (code) goto _err;
|
||||
code = metaFinishCommit(pWriter->pMeta);
|
||||
code = metaFinishCommit(pWriter->pMeta, pWriter->pMeta->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
taosMemoryFree(pWriter);
|
||||
|
|
|
@ -261,7 +261,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
|||
// drop all child tables
|
||||
TBC *pCtbIdxc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL);
|
||||
rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c);
|
||||
if (rc < 0) {
|
||||
tdbTbcClose(pCtbIdxc);
|
||||
|
@ -295,10 +295,10 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb
|
|||
_drop_super_table:
|
||||
tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData);
|
||||
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid},
|
||||
sizeof(STbDbKey), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn);
|
||||
sizeof(STbDbKey), pMeta->txn);
|
||||
tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn);
|
||||
tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||
tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn);
|
||||
|
||||
metaULock(pMeta);
|
||||
|
||||
|
@ -321,7 +321,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
int32_t ret;
|
||||
int32_t c = -2;
|
||||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
|
||||
if (ret < 0 || c) {
|
||||
tdbTbcClose(pUidIdxc);
|
||||
|
@ -340,7 +340,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
oversion = ((SUidIdxVal *)pData)[0].version;
|
||||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(ret == 0 && c == 0);
|
||||
|
||||
|
@ -595,7 +595,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
STtlIdxKey ttlKey = {0};
|
||||
metaBuildTtlIdxKey(&ttlKey, pME);
|
||||
if (ttlKey.dtime == 0) return 0;
|
||||
return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), &pMeta->txn);
|
||||
return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||
|
@ -657,7 +657,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
|
||||
if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid,
|
||||
&pTagIdxKey, &nTagIdxKey) == 0) {
|
||||
tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn);
|
||||
}
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
}
|
||||
|
@ -667,9 +667,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
}
|
||||
}
|
||||
|
||||
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn);
|
||||
tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn);
|
||||
tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn);
|
||||
|
||||
if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteCtimeIdx(pMeta, &e);
|
||||
if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e);
|
||||
|
@ -677,7 +677,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
if (e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e);
|
||||
|
||||
if (e.type == TSDB_CHILD_TABLE) {
|
||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn);
|
||||
|
||||
--pMeta->pVnode->config.vndStats.numOfCTables;
|
||||
|
||||
|
@ -689,7 +689,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
--pMeta->pVnode->config.vndStats.numOfNTables;
|
||||
pMeta->pVnode->config.vndStats.numOfNTimeSeries -= e.ntbEntry.schemaRow.nCols - 1;
|
||||
} else if (e.type == TSDB_SUPER_TABLE) {
|
||||
tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), &pMeta->txn);
|
||||
tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn);
|
||||
// drop schema.db (todo)
|
||||
|
||||
metaStatsCacheDrop(pMeta, uid);
|
||||
|
@ -710,7 +710,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
||||
int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
|
@ -718,14 +718,14 @@ int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), &pMeta->txn);
|
||||
return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), pMeta->txn);
|
||||
}
|
||||
int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
SNcolIdxKey ncolKey = {0};
|
||||
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
||||
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
|
@ -733,7 +733,7 @@ int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), &pMeta->txn);
|
||||
return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
||||
|
@ -768,7 +768,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
// search uid index
|
||||
TBC *pUidIdxc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
|
||||
|
@ -778,7 +778,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
|
|||
// search table.db
|
||||
TBC *pTbDbc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
@ -959,7 +959,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
// search uid index
|
||||
TBC *pUidIdxc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
|
||||
|
@ -972,7 +972,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
SDecoder dc2 = {0};
|
||||
|
||||
/* get ctbEntry */
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
@ -1075,7 +1075,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
ASSERT(ctbEntry.ctbEntry.pTags);
|
||||
SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid};
|
||||
tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags,
|
||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, &pMeta->txn);
|
||||
((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn);
|
||||
|
||||
metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
// search uid index
|
||||
TBC *pUidIdxc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
|
||||
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
|
||||
ASSERT(c == 0);
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
|
|||
// search table.db
|
||||
TBC *pTbDbc = NULL;
|
||||
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
|
||||
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||
ASSERT(c == 0);
|
||||
tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||
|
@ -1432,7 +1432,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
tEncoderClear(&coder);
|
||||
|
||||
// write to table.db
|
||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) {
|
||||
if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -1455,29 +1455,29 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
|
||||
SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer};
|
||||
|
||||
return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn);
|
||||
return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
STtlIdxKey ttlKey = {0};
|
||||
metaBuildTtlIdxKey(&ttlKey, pME);
|
||||
if (ttlKey.dtime == 0) return 0;
|
||||
return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, &pMeta->txn);
|
||||
return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, pMeta->txn);
|
||||
}
|
||||
|
||||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
||||
|
||||
return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags,
|
||||
((STag *)(pME->ctbEntry.pTags))->len, &pMeta->txn);
|
||||
((STag *)(pME->ctbEntry.pTags))->len, pMeta->txn);
|
||||
}
|
||||
|
||||
int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid,
|
||||
|
@ -1569,7 +1569,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
|||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn);
|
||||
tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn);
|
||||
}
|
||||
end:
|
||||
metaDestroyTagIdxKey(pTagIdxKey);
|
||||
|
@ -1616,7 +1616,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
tEncoderInit(&coder, pVal, vLen);
|
||||
tEncodeSSchemaWrapper(&coder, pSW);
|
||||
|
||||
if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) {
|
||||
if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) {
|
||||
rcode = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
|
|||
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
|
||||
#endif
|
||||
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
|
||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
|
||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo);
|
||||
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
|
||||
static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
|
||||
|
||||
|
@ -59,7 +59,7 @@ int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(p
|
|||
* @param pSma
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
|
||||
int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); }
|
||||
|
||||
/**
|
||||
* @brief async commit, only applicable to Rollup SMA
|
||||
|
@ -67,7 +67,7 @@ int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma);
|
|||
* @param pSma
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t smaCommit(SSma *pSma) { return tdProcessRSmaAsyncCommitImpl(pSma); }
|
||||
int32_t smaCommit(SSma *pSma, SCommitInfo *pInfo) { return tdProcessRSmaAsyncCommitImpl(pSma, pInfo); }
|
||||
|
||||
/**
|
||||
* @brief async commit, only applicable to Rollup SMA
|
||||
|
@ -127,8 +127,8 @@ _exit:
|
|||
}
|
||||
|
||||
int32_t smaFinishCommit(SSma *pSma) {
|
||||
int32_t code = 0;
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
int32_t code = 0;
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
|
||||
if (VND_RSMA1(pVnode) && (code = tsdbFinishCommit(VND_RSMA1(pVnode))) < 0) {
|
||||
smaError("vgId:%d, failed to finish commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||
|
@ -378,6 +378,11 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
|||
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
|
||||
#endif
|
||||
|
||||
// all rsma results are written completely
|
||||
STsdb *pTsdb = NULL;
|
||||
if ((pTsdb = VND_RSMA1(pSma->pVnode))) tsdbPrepareCommit(pTsdb);
|
||||
if ((pTsdb = VND_RSMA2(pSma->pVnode))) tsdbPrepareCommit(pTsdb);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -387,9 +392,9 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
|
|||
* @param pSma
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
||||
int32_t code = 0;
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) {
|
||||
int32_t code = 0;
|
||||
SVnode *pVnode = pSma->pVnode;
|
||||
#if 0
|
||||
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv);
|
||||
|
||||
|
@ -399,11 +404,11 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
|
|||
}
|
||||
#endif
|
||||
|
||||
if ((code = tsdbCommit(VND_RSMA1(pVnode))) < 0) {
|
||||
if ((code = tsdbCommit(VND_RSMA1(pVnode), pInfo)) < 0) {
|
||||
smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
if ((code = tsdbCommit(VND_RSMA2(pVnode))) < 0) {
|
||||
if ((code = tsdbCommit(VND_RSMA2(pVnode), pInfo)) < 0) {
|
||||
smaError("vgId:%d, failed to commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(code));
|
||||
goto _exit;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ static void tqPushEntryFree(void* data) {
|
|||
STQ* tqOpen(const char* path, SVnode* pVnode) {
|
||||
STQ* pTq = taosMemoryCalloc(1, sizeof(STQ));
|
||||
if (pTq == NULL) {
|
||||
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pTq->path = strdup(path);
|
||||
|
|
|
@ -25,7 +25,7 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
|
|||
pRetrieve->precision = precision;
|
||||
pRetrieve->compressed = 0;
|
||||
pRetrieve->completed = 1;
|
||||
pRetrieve->numOfRows = htonl(pBlock->info.rows);
|
||||
pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||
|
||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||
actualLen += sizeof(SRetrieveTableRsp);
|
||||
|
|
|
@ -108,24 +108,22 @@ int32_t tqMetaClose(STQ* pTq) {
|
|||
}
|
||||
|
||||
int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_t vLen) {
|
||||
TXN txn;
|
||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
TXN* txn;
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, &txn) < 0) {
|
||||
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -133,25 +131,22 @@ int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_
|
|||
}
|
||||
|
||||
int32_t tqMetaDeleteCheckInfo(STQ* pTq, const char* key) {
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
|
||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), &txn) < 0) {
|
||||
if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), txn) < 0) {
|
||||
/*ASSERT(0);*/
|
||||
}
|
||||
|
||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
@ -219,25 +214,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
|||
ASSERT(0);
|
||||
}
|
||||
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
|
||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, &txn) < 0) {
|
||||
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
@ -247,25 +239,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
|
|||
}
|
||||
|
||||
int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) {
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
|
||||
if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) {
|
||||
if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) <
|
||||
0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbBegin(pTq->pMetaDB, &txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), &txn) < 0) {
|
||||
if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), txn) < 0) {
|
||||
/*ASSERT(0);*/
|
||||
}
|
||||
|
||||
if (tdbCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) {
|
||||
if (tdbPostCommit(pTq->pMetaDB, txn) < 0) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
|||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
ASSERT(0);
|
||||
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
code = -1;
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
|
@ -165,11 +167,11 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
|||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaDB, &pWriter->txn);
|
||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
|||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
ASSERT(0);
|
||||
if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
code = -1;
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
|
@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
|||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
ASSERT(0);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn);
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ struct STqSnapWriter {
|
|||
STQ* pTq;
|
||||
int64_t sver;
|
||||
int64_t ever;
|
||||
TXN txn;
|
||||
TXN* txn;
|
||||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
|
@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p
|
|||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
ASSERT(0);
|
||||
if (tdbBegin(pTq->pMetaStore, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) {
|
||||
code = -1;
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
*ppWriter = pWriter;
|
||||
|
@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
|||
STQ* pTq = pWriter->pTq;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||
ASSERT(0);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
||||
code = tdbCommit(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaStore, &pWriter->txn);
|
||||
code = tdbPostCommit(pWriter->pTq->pMetaStore, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,23 +228,23 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
|
|||
invalidate = true;
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||
} else { // new inserting key is greater than cached, update cached entry
|
||||
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||
|
||||
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||
if (lastCol.colVal.value.pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _invalidate;
|
||||
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||
if (lastCol.colVal.value.pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _invalidate;
|
||||
}
|
||||
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||
}
|
||||
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||
}
|
||||
|
||||
taosArraySet(pLast, iCol, &lastCol);
|
||||
taosArraySet(pLast, iCol, &lastCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,65 +253,10 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
|
|||
taosMemoryFreeClear(pTSchema);
|
||||
|
||||
taosLRUCacheRelease(pCache, h, invalidate);
|
||||
/*
|
||||
cacheRow = (STSRow *)taosLRUCacheValue(pCache, h);
|
||||
if (row->ts >= cacheRow->ts) {
|
||||
if (row->ts == cacheRow->ts) {
|
||||
STSRow *mergedRow = NULL;
|
||||
SRowMerger merger = {0};
|
||||
STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1, 1);
|
||||
|
||||
tRowMergerInit(&merger, &tsdbRowFromTSRow(0, cacheRow), pTSchema);
|
||||
|
||||
tRowMerge(&merger, &tsdbRowFromTSRow(1, row));
|
||||
|
||||
tRowMergerGetRow(&merger, &mergedRow);
|
||||
tRowMergerClear(&merger);
|
||||
|
||||
taosMemoryFreeClear(pTSchema);
|
||||
|
||||
row = mergedRow;
|
||||
dup = false;
|
||||
}
|
||||
|
||||
if (TD_ROW_LEN(row) <= TD_ROW_LEN(cacheRow)) {
|
||||
tdRowCpy(cacheRow, row);
|
||||
if (!dup) {
|
||||
taosMemoryFree(row);
|
||||
}
|
||||
|
||||
taosLRUCacheRelease(pCache, h, false);
|
||||
} else {
|
||||
taosLRUCacheRelease(pCache, h, true);
|
||||
// tsdbCacheDeleteLastrow(pCache, uid, TSKEY_MAX);
|
||||
if (dup) {
|
||||
cacheRow = tdRowDup(row);
|
||||
} else {
|
||||
cacheRow = row;
|
||||
}
|
||||
_taos_lru_deleter_t deleter = deleteTableCacheLastrow;
|
||||
LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, cacheRow, TD_ROW_LEN(cacheRow), deleter, NULL,
|
||||
TAOS_LRU_PRIORITY_LOW);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
code = -1;
|
||||
}
|
||||
// tsdbCacheInsertLastrow(pCache, uid, row, dup);
|
||||
}
|
||||
}*/
|
||||
} /*else {
|
||||
if (dup) {
|
||||
cacheRow = tdRowDup(row);
|
||||
} else {
|
||||
cacheRow = row;
|
||||
if (invalidate) {
|
||||
taosLRUCacheErase(pCache, key, keyLen);
|
||||
}
|
||||
|
||||
_taos_lru_deleter_t deleter = deleteTableCacheLastrow;
|
||||
LRUStatus status =
|
||||
taosLRUCacheInsert(pCache, key, keyLen, cacheRow, TD_ROW_LEN(cacheRow), deleter, NULL, TAOS_LRU_PRIORITY_LOW);
|
||||
if (status != TAOS_LRU_STATUS_OK) {
|
||||
code = -1;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -349,28 +294,28 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb
|
|||
|
||||
SColVal colVal = {0};
|
||||
tTSRowGetVal(row, pTSchema, iCol, &colVal);
|
||||
if (!COL_VAL_IS_VALUE(&colVal)) {
|
||||
if (COL_VAL_IS_VALUE(&colVal)) {
|
||||
if (keyTs == tTsVal1->ts && COL_VAL_IS_VALUE(tColVal)) {
|
||||
invalidate = true;
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||
} else {
|
||||
SLastCol lastCol = {.ts = keyTs, .colVal = colVal};
|
||||
if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) {
|
||||
SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol);
|
||||
taosMemoryFree(pLastCol->colVal.value.pData);
|
||||
|
||||
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||
if (lastCol.colVal.value.pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _invalidate;
|
||||
lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData);
|
||||
if (lastCol.colVal.value.pData == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _invalidate;
|
||||
}
|
||||
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||
}
|
||||
memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData);
|
||||
}
|
||||
|
||||
taosArraySet(pLast, iCol, &lastCol);
|
||||
taosArraySet(pLast, iCol, &lastCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -379,9 +324,9 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb
|
|||
taosMemoryFreeClear(pTSchema);
|
||||
|
||||
taosLRUCacheRelease(pCache, h, invalidate);
|
||||
|
||||
// clear last cache anyway, lazy load when get last lookup
|
||||
// taosLRUCacheRelease(pCache, h, true);
|
||||
if (invalidate) {
|
||||
taosLRUCacheErase(pCache, key, keyLen);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -93,7 +93,7 @@ typedef struct {
|
|||
SArray *aDelData; // SArray<SDelData>
|
||||
} SCommitter;
|
||||
|
||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter);
|
||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo);
|
||||
static int32_t tsdbCommitData(SCommitter *pCommitter);
|
||||
static int32_t tsdbCommitDel(SCommitter *pCommitter);
|
||||
static int32_t tsdbCommitCache(SCommitter *pCommitter);
|
||||
|
@ -150,18 +150,28 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbCommit(STsdb *pTsdb) {
|
||||
int32_t tsdbPrepareCommit(STsdb *pTsdb) {
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
ASSERT(pTsdb->imem == NULL);
|
||||
pTsdb->imem = pTsdb->mem;
|
||||
pTsdb->mem = NULL;
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbCommit(STsdb *pTsdb, SCommitInfo *pInfo) {
|
||||
if (!pTsdb) return 0;
|
||||
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SCommitter commith;
|
||||
SMemTable *pMemTable = pTsdb->mem;
|
||||
SMemTable *pMemTable = pTsdb->imem;
|
||||
|
||||
// check
|
||||
if (pMemTable->nRow == 0 && pMemTable->nDel == 0) {
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->mem = NULL;
|
||||
pTsdb->imem = NULL;
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
|
||||
tsdbUnrefMemTable(pMemTable);
|
||||
|
@ -169,7 +179,7 @@ int32_t tsdbCommit(STsdb *pTsdb) {
|
|||
}
|
||||
|
||||
// start commit
|
||||
code = tsdbStartCommit(pTsdb, &commith);
|
||||
code = tsdbStartCommit(pTsdb, &commith, pInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
// commit impl
|
||||
|
@ -806,26 +816,21 @@ _exit:
|
|||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
|
||||
static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
memset(pCommitter, 0, sizeof(*pCommitter));
|
||||
ASSERT(pTsdb->mem && pTsdb->imem == NULL && "last tsdb commit incomplete");
|
||||
|
||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||
pTsdb->imem = pTsdb->mem;
|
||||
pTsdb->mem = NULL;
|
||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||
ASSERT(pTsdb->imem && "last tsdb commit incomplete");
|
||||
|
||||
pCommitter->pTsdb = pTsdb;
|
||||
pCommitter->commitID = pTsdb->pVnode->state.commitID;
|
||||
pCommitter->commitID = pInfo->info.state.commitID;
|
||||
pCommitter->minutes = pTsdb->keepCfg.days;
|
||||
pCommitter->precision = pTsdb->keepCfg.precision;
|
||||
pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows;
|
||||
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
|
||||
pCommitter->sttTrigger = pTsdb->pVnode->config.sttTrigger;
|
||||
pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows;
|
||||
pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
|
||||
pCommitter->sttTrigger = pInfo->info.config.sttTrigger;
|
||||
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
||||
if (pCommitter->aTbDataP == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -84,8 +84,8 @@ typedef struct SIOCostSummary {
|
|||
typedef struct SBlockLoadSuppInfo {
|
||||
SArray* pColAgg;
|
||||
SColumnDataAgg tsColAgg;
|
||||
SColumnDataAgg** plist;
|
||||
int16_t* colIds; // column ids for loading file block data
|
||||
int16_t* colId;
|
||||
int16_t* slotId;
|
||||
int32_t numOfCols;
|
||||
char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated.
|
||||
bool smaValid; // the sma on all queried columns are activated
|
||||
|
@ -158,6 +158,7 @@ struct STsdbReader {
|
|||
STsdb* pTsdb;
|
||||
uint64_t suid;
|
||||
int16_t order;
|
||||
bool freeBlock;
|
||||
STimeWindow window; // the primary query time window that applies to all queries
|
||||
SSDataBlock* pResBlock;
|
||||
int32_t capacity;
|
||||
|
@ -169,7 +170,9 @@ struct STsdbReader {
|
|||
SIOCostSummary cost;
|
||||
STSchema* pSchema; // the newest version schema
|
||||
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
||||
SDataFReader* pFileReader;
|
||||
SDataFReader* pFileReader; // the file reader
|
||||
SDelFReader* pDelFReader; // the del file reader
|
||||
SArray* pDelIdx; // del file block index;
|
||||
SVersionRange verRange;
|
||||
SBlockInfoBuf blockInfoBuf;
|
||||
int32_t step;
|
||||
|
@ -214,25 +217,25 @@ static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFil
|
|||
|
||||
static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
|
||||
|
||||
static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SSDataBlock* pBlock) {
|
||||
size_t numOfCols = blockDataGetNumOfCols(pBlock);
|
||||
|
||||
static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, int32_t numOfCols) {
|
||||
pSupInfo->smaValid = true;
|
||||
pSupInfo->numOfCols = numOfCols;
|
||||
pSupInfo->colIds = taosMemoryMalloc(numOfCols * sizeof(int16_t));
|
||||
pSupInfo->buildBuf = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||
if (pSupInfo->buildBuf == NULL || pSupInfo->colIds == NULL) {
|
||||
taosMemoryFree(pSupInfo->colIds);
|
||||
taosMemoryFree(pSupInfo->buildBuf);
|
||||
pSupInfo->colId = taosMemoryMalloc(numOfCols * (sizeof(int16_t)*2 + POINTER_BYTES));
|
||||
if (pSupInfo->colId == NULL) {
|
||||
taosMemoryFree(pSupInfo->colId);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pSupInfo->slotId = (int16_t*)((char*)pSupInfo->colId + (sizeof(int16_t) * numOfCols));
|
||||
pSupInfo->buildBuf = (char**) ((char*)pSupInfo->slotId + (sizeof(int16_t) * numOfCols));
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i);
|
||||
pSupInfo->colIds[i] = pCol->info.colId;
|
||||
pSupInfo->colId[i] = pCols[i].colId;
|
||||
pSupInfo->slotId[i] = pSlotIdList[i];
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pCol->info.type)) {
|
||||
pSupInfo->buildBuf[i] = taosMemoryMalloc(pCol->info.bytes);
|
||||
if (IS_VAR_DATA_TYPE(pCols[i].type)) {
|
||||
pSupInfo->buildBuf[i] = taosMemoryMalloc(pCols[i].bytes);
|
||||
} else {
|
||||
pSupInfo->buildBuf[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +247,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
|||
|
||||
while(i < pSchema->numOfCols && j < pSupInfo->numOfCols) {
|
||||
STColumn* pTCol = &pSchema->columns[i];
|
||||
if (pTCol->colId == pSupInfo->colIds[j]) {
|
||||
if (pTCol->colId == pSupInfo->colId[j]) {
|
||||
if (!IS_BSMA_ON(pTCol)) {
|
||||
pSupInfo->smaValid = false;
|
||||
return;
|
||||
|
@ -252,7 +255,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
|
|||
|
||||
i += 1;
|
||||
j += 1;
|
||||
} else if (pTCol->colId < pSupInfo->colIds[j]) {
|
||||
} else if (pTCol->colId < pSupInfo->colId[j]) {
|
||||
// do nothing
|
||||
i += 1;
|
||||
} else {
|
||||
|
@ -454,7 +457,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
|
|||
if (pLReader->pInfo == NULL) {
|
||||
// here we ignore the first column, which is always be the primary timestamp column
|
||||
pLReader->pInfo =
|
||||
tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols - 1);
|
||||
tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1);
|
||||
if (pLReader->pInfo == NULL) {
|
||||
tsdbDebug("init fileset iterator failed, code:%s %s", tstrerror(terrno), pReader->idStr);
|
||||
return terrno;
|
||||
|
@ -566,7 +569,7 @@ static SSDataBlock* createResBlock(SQueryTableDataCond* pCond, int32_t capacity)
|
|||
}
|
||||
|
||||
static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsdbReader** ppReader, int32_t capacity,
|
||||
const char* idstr) {
|
||||
SSDataBlock* pResBlock, const char* idstr) {
|
||||
int32_t code = 0;
|
||||
int8_t level = 0;
|
||||
STsdbReader* pReader = (STsdbReader*)taosMemoryCalloc(1, sizeof(*pReader));
|
||||
|
@ -585,6 +588,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
pReader->suid = pCond->suid;
|
||||
pReader->order = pCond->order;
|
||||
pReader->capacity = capacity;
|
||||
pReader->pResBlock = pResBlock;
|
||||
pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL;
|
||||
pReader->verRange = getQueryVerRange(pVnode, pCond, level);
|
||||
pReader->type = pCond->type;
|
||||
|
@ -592,13 +596,22 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket
|
||||
ASSERT(pCond->numOfCols > 0);
|
||||
|
||||
if (pReader->pResBlock == NULL) {
|
||||
pReader->freeBlock = true;
|
||||
pReader->pResBlock = createResBlock(pCond, pReader->capacity);
|
||||
if (pReader->pResBlock == NULL) {
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
}
|
||||
|
||||
// todo refactor.
|
||||
limitOutputBufferSize(pCond, &pReader->capacity);
|
||||
|
||||
// allocate buffer in order to load data blocks from file
|
||||
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
||||
pSup->pColAgg = taosArrayInit(pCond->numOfCols, sizeof(SColumnDataAgg));
|
||||
pSup->plist = taosMemoryCalloc(pCond->numOfCols, POINTER_BYTES);
|
||||
if (pSup->pColAgg == NULL || pSup->plist == NULL) {
|
||||
if (pSup->pColAgg == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _end;
|
||||
}
|
||||
|
@ -611,13 +624,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
|
|||
goto _end;
|
||||
}
|
||||
|
||||
pReader->pResBlock = createResBlock(pCond, pReader->capacity);
|
||||
if (pReader->pResBlock == NULL) {
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
setColumnIdSlotList(&pReader->suppInfo, pReader->pResBlock);
|
||||
setColumnIdSlotList(&pReader->suppInfo, pCond->colList, pCond->pSlotList, pCond->numOfCols);
|
||||
|
||||
*ppReader = pReader;
|
||||
return code;
|
||||
|
@ -1044,17 +1051,16 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
|
|||
}
|
||||
|
||||
static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) {
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
SDataBlockIter* pBlockIter = &pStatus->blockIter;
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
|
||||
SBlockData* pBlockData = &pStatus->fileBlockData;
|
||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
|
||||
SDataBlk* pBlock = getCurrentBlock(pBlockIter);
|
||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
||||
int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock);
|
||||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
int32_t numOfOutputCols = pSupInfo->numOfCols;
|
||||
|
||||
SColVal cv = {0};
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
@ -1090,8 +1096,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
int32_t i = 0;
|
||||
int32_t rowIndex = 0;
|
||||
|
||||
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||
if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
if (pSupInfo->colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
copyPrimaryTsCol(pBlockData, pDumpInfo, pColData, dumpedRows, asc);
|
||||
i += 1;
|
||||
}
|
||||
|
@ -1100,12 +1106,13 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
int32_t num = pBlockData->nColData;
|
||||
while (i < numOfOutputCols && colIndex < num) {
|
||||
rowIndex = 0;
|
||||
pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||
|
||||
SColData* pData = tBlockDataGetColDataByIdx(pBlockData, colIndex);
|
||||
if (pData->cid < pColData->info.colId) {
|
||||
if (pData->cid < pSupInfo->colId[i]) {
|
||||
colIndex += 1;
|
||||
} else if (pData->cid == pColData->info.colId) {
|
||||
} else if (pData->cid == pSupInfo->colId[i]) {
|
||||
pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
|
||||
if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL | HAS_NONE)) {
|
||||
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||
} else {
|
||||
|
@ -1122,6 +1129,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
colIndex += 1;
|
||||
i += 1;
|
||||
} else { // the specified column does not exist in file block, fill with null data
|
||||
pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||
i += 1;
|
||||
}
|
||||
|
@ -1129,7 +1137,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
|
||||
// fill the mis-matched columns with null value
|
||||
while (i < numOfOutputCols) {
|
||||
pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||
pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
colDataAppendNNULL(pColData, 0, dumpedRows);
|
||||
i += 1;
|
||||
}
|
||||
|
@ -1167,7 +1175,7 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
|
|||
tBlockDataReset(pBlockData);
|
||||
TABLEID tid = {.suid = pReader->suid, .uid = uid};
|
||||
int32_t code =
|
||||
tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols - 1);
|
||||
tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
@ -1305,7 +1313,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
char* buf = taosMemoryMalloc(sizeof(SBlockOrderWrapper) * num);
|
||||
if (buf == NULL) {
|
||||
cleanupBlockOrderSupporter(&sup);
|
||||
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf;
|
||||
|
@ -1348,7 +1356,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
|
|||
uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
cleanupBlockOrderSupporter(&sup);
|
||||
return TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t numOfTotal = 0;
|
||||
|
@ -1626,7 +1634,7 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo*
|
|||
int64_t st = taosGetTimestampUs();
|
||||
int32_t code = buildDataBlockFromBufImpl(pBlockScanInfo, endKey, pReader->capacity, pReader);
|
||||
|
||||
blockDataUpdateTsWindow(pBlock, 0);
|
||||
blockDataUpdateTsWindow(pBlock, pReader->suppInfo.slotId[0]);
|
||||
pBlock->info.id.uid = pBlockScanInfo->uid;
|
||||
|
||||
setComposedBlockFlag(pReader, true);
|
||||
|
@ -2498,7 +2506,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
|
||||
_end:
|
||||
pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0;
|
||||
blockDataUpdateTsWindow(pResBlock, 0);
|
||||
blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]);
|
||||
|
||||
setComposedBlockFlag(pReader, true);
|
||||
double el = (taosGetTimestampUs() - st) / 1000.0;
|
||||
|
@ -2525,42 +2533,18 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
|||
}
|
||||
|
||||
int32_t code = 0;
|
||||
STsdb* pTsdb = pReader->pTsdb;
|
||||
|
||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||
ASSERT(pReader->pReadSnap != NULL);
|
||||
|
||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||
if (pDelFile) {
|
||||
SDelFReader* pDelFReader = NULL;
|
||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
||||
SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
||||
if (aDelIdx == NULL) {
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
// TODO: opt the perf of read del index
|
||||
code = tsdbReadDelIdx(pDelFReader, aDelIdx);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(aDelIdx);
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
||||
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
||||
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||
SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||
|
||||
if (pIdx != NULL) {
|
||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData);
|
||||
code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData);
|
||||
}
|
||||
|
||||
taosArrayDestroy(aDelIdx);
|
||||
tsdbDelFReaderClose(&pDelFReader);
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -2656,6 +2640,30 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
|
|||
}
|
||||
|
||||
taosArrayDestroy(pIndexList);
|
||||
|
||||
if (pReader->pReadSnap != NULL) {
|
||||
|
||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||
if (pReader->pDelFReader == NULL && pDelFile != NULL) {
|
||||
int32_t code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pReader->pTsdb);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
return code;
|
||||
}
|
||||
|
||||
pReader->pDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
||||
if (pReader->pDelIdx == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
code = tsdbReadDelIdx(pReader->pDelFReader, pReader->pDelIdx);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosArrayDestroy(pReader->pDelIdx);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3539,8 +3547,7 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR
|
|||
|
||||
int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow,
|
||||
STableBlockScanInfo* pScanInfo) {
|
||||
int32_t numOfRows = pBlock->info.rows;
|
||||
int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock);
|
||||
int32_t outputRowIndex = pBlock->info.rows;
|
||||
int64_t uid = pScanInfo->uid;
|
||||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
@ -3549,23 +3556,26 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
|
|||
SColVal colVal = {0};
|
||||
int32_t i = 0, j = 0;
|
||||
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (pColInfoData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
colDataAppend(pColInfoData, numOfRows, (const char*)&pTSRow->ts, false);
|
||||
if (pSupInfo->colId[i]== PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
((int64_t*)pColData->pData)[outputRowIndex] = pTSRow->ts;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
while (i < numOfCols && j < pSchema->numOfCols) {
|
||||
pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
col_id_t colId = pColInfoData->info.colId;
|
||||
while (i < pSupInfo->numOfCols && j < pSchema->numOfCols) {
|
||||
col_id_t colId = pSupInfo->colId[i];
|
||||
|
||||
if (colId == pSchema->columns[j].colId) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
|
||||
tTSRowGetVal(pTSRow, pSchema, j, &colVal);
|
||||
doCopyColVal(pColInfoData, numOfRows, i, &colVal, pSupInfo);
|
||||
doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo);
|
||||
i += 1;
|
||||
j += 1;
|
||||
} else if (colId < pSchema->columns[j].colId) {
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
|
||||
colDataAppendNULL(pColInfoData, outputRowIndex);
|
||||
i += 1;
|
||||
} else if (colId > pSchema->columns[j].colId) {
|
||||
j += 1;
|
||||
|
@ -3573,9 +3583,9 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
|
|||
}
|
||||
|
||||
// set null value since current column does not exist in the "pSchema"
|
||||
while (i < numOfCols) {
|
||||
pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
colDataAppendNULL(pColInfoData, numOfRows);
|
||||
while (i < pSupInfo->numOfCols) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
colDataAppendNULL(pColInfoData, outputRowIndex);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -3590,27 +3600,25 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
|
|||
int32_t outputRowIndex = pResBlock->info.rows;
|
||||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
||||
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i);
|
||||
if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
colDataAppendInt64(pColData, outputRowIndex, &pBlockData->aTSKEY[rowIndex]);
|
||||
if (pReader->suppInfo.colId[i]== PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
((int64_t*)pColData->pData)[outputRowIndex] = pBlockData->aTSKEY[rowIndex];
|
||||
i += 1;
|
||||
}
|
||||
|
||||
SColVal cv = {0};
|
||||
int32_t numOfInputCols = pBlockData->nColData;
|
||||
int32_t numOfOutputCols = pResBlock->pDataBlock->size;
|
||||
int32_t numOfOutputCols = pSupInfo->numOfCols;
|
||||
|
||||
while (i < numOfOutputCols && j < numOfInputCols) {
|
||||
SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, i);
|
||||
SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j);
|
||||
|
||||
if (pData->cid < pCol->info.colId) {
|
||||
SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j);
|
||||
if (pData->cid < pSupInfo->colId[i]) {
|
||||
j += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pData->cid == pCol->info.colId) {
|
||||
SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
if (pData->cid == pSupInfo->colId[i]) {
|
||||
tColDataGetValue(pData, rowIndex, &cv);
|
||||
doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo);
|
||||
j += 1;
|
||||
|
@ -3623,7 +3631,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
|
|||
}
|
||||
|
||||
while (i < numOfOutputCols) {
|
||||
SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i);
|
||||
SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]);
|
||||
colDataAppendNULL(pCol, outputRowIndex);
|
||||
i += 1;
|
||||
}
|
||||
|
@ -3722,14 +3730,21 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) {
|
|||
|
||||
// ====================================== EXPOSED APIs ======================================
|
||||
int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
|
||||
STsdbReader** ppReader, const char* idstr) {
|
||||
SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr) {
|
||||
STimeWindow window = pCond->twindows;
|
||||
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
pCond->twindows.skey += 1;
|
||||
pCond->twindows.ekey -= 1;
|
||||
}
|
||||
|
||||
int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, 4096, idstr);
|
||||
int32_t capacity = 0;
|
||||
if (pResBlock == NULL) {
|
||||
capacity = 4096;
|
||||
} else {
|
||||
capacity = pResBlock->info.capacity;
|
||||
}
|
||||
|
||||
int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, capacity, pResBlock, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -3755,7 +3770,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
}
|
||||
|
||||
// here we only need one more row, so the capacity is set to be ONE.
|
||||
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[0], 1, idstr);
|
||||
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[0], 1, pResBlock, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -3769,7 +3784,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
}
|
||||
pCond->order = order;
|
||||
|
||||
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr);
|
||||
code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, pResBlock, idstr);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _err;
|
||||
}
|
||||
|
@ -3799,7 +3814,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
tsdbReaderClose(p);
|
||||
*ppReader = NULL;
|
||||
|
||||
code = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
|
@ -3841,10 +3856,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
_err:
|
||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
void tsdbReaderClose(STsdbReader* pReader) {
|
||||
if (pReader == NULL) {
|
||||
|
@ -3874,19 +3889,19 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
|
||||
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
|
||||
|
||||
taosMemoryFreeClear(pSupInfo->plist);
|
||||
taosMemoryFree(pSupInfo->colIds);
|
||||
|
||||
taosArrayDestroy(pSupInfo->pColAgg);
|
||||
for (int32_t i = 0; i < blockDataGetNumOfCols(pReader->pResBlock); ++i) {
|
||||
for (int32_t i = 0; i < pSupInfo->numOfCols; ++i) {
|
||||
if (pSupInfo->buildBuf[i] != NULL) {
|
||||
taosMemoryFreeClear(pSupInfo->buildBuf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pSupInfo->buildBuf);
|
||||
tBlockDataDestroy(&pReader->status.fileBlockData, true);
|
||||
if (pReader->freeBlock) {
|
||||
pReader->pResBlock = blockDataDestroy(pReader->pResBlock);
|
||||
}
|
||||
|
||||
taosMemoryFree(pSupInfo->colId);
|
||||
tBlockDataDestroy(&pReader->status.fileBlockData, true);
|
||||
cleanupDataBlockIterator(&pReader->status.blockIter);
|
||||
|
||||
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||
|
@ -3895,12 +3910,19 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||
}
|
||||
|
||||
blockDataDestroy(pReader->pResBlock);
|
||||
|
||||
if (pReader->pFileReader != NULL) {
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
}
|
||||
|
||||
if (pReader->pDelFReader != NULL) {
|
||||
tsdbDelFReaderClose(&pReader->pDelFReader);
|
||||
}
|
||||
|
||||
if (pReader->pDelIdx != NULL) {
|
||||
taosArrayDestroy(pReader->pDelIdx);
|
||||
pReader->pDelIdx = NULL;
|
||||
}
|
||||
|
||||
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr);
|
||||
|
||||
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
|
||||
|
@ -3942,6 +3964,9 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
|
|||
blockDataCleanup(pBlock);
|
||||
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
if (taosHashGetSize(pStatus->pTableMap) == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pStatus->loadFromFile) {
|
||||
int32_t code = buildBlockFromFiles(pReader);
|
||||
|
@ -3959,8 +3984,6 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) {
|
|||
buildBlockFromBufferSequentially(pReader);
|
||||
return pBlock->info.rows > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||
|
@ -4011,16 +4034,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) {
|
||||
STableBlockScanInfo* pBlockScanInfo =
|
||||
*(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid));
|
||||
if (pBlockScanInfo == NULL) { // no data block for the table of given uid
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) {
|
||||
ASSERT(pReader != NULL);
|
||||
*rows = pReader->pResBlock->info.rows;
|
||||
|
@ -4042,28 +4055,27 @@ void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64
|
|||
}
|
||||
}
|
||||
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockStatis, bool* allHave) {
|
||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg ***pBlockSMA, bool* allHave) {
|
||||
int32_t code = 0;
|
||||
*allHave = false;
|
||||
|
||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
*pBlockStatis = NULL;
|
||||
*pBlockSMA = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// there is no statistics data for composed block
|
||||
if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) {
|
||||
*pBlockStatis = NULL;
|
||||
*pBlockSMA = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
|
||||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
// int64_t stime = taosGetTimestampUs();
|
||||
|
||||
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
|
||||
|
||||
ASSERT(pReader->pResBlock->info.id.uid == pFBlock->uid);
|
||||
|
||||
SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
|
||||
if (tDataBlkHasSma(pBlock)) {
|
||||
code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -4072,7 +4084,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
return code;
|
||||
}
|
||||
} else {
|
||||
*pBlockStatis = NULL;
|
||||
*pBlockSMA = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -4085,80 +4097,53 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
pTsAgg->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
pTsAgg->min = pReader->pResBlock->info.window.skey;
|
||||
pTsAgg->max = pReader->pResBlock->info.window.ekey;
|
||||
pSup->plist[0] = pTsAgg;
|
||||
|
||||
// update the number of NULL data rows
|
||||
size_t numOfCols = blockDataGetNumOfCols(pReader->pResBlock);
|
||||
size_t numOfCols = pSup->numOfCols;
|
||||
|
||||
int32_t i = 0, j = 0;
|
||||
size_t size = taosArrayGetSize(pSup->pColAgg);
|
||||
#if 0
|
||||
while (j < numOfCols && i < size) {
|
||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||
if (pAgg->colId == pSup->colIds[j]) {
|
||||
if (IS_BSMA_ON(&(pReader->pSchema->columns[i]))) {
|
||||
pSup->plist[j] = pAgg;
|
||||
} else {
|
||||
*allHave = false;
|
||||
break;
|
||||
}
|
||||
i += 1;
|
||||
j += 1;
|
||||
} else if (pAgg->colId < pSup->colIds[j]) {
|
||||
i += 1;
|
||||
} else if (pSup->colIds[j] < pAgg->colId) {
|
||||
j += 1;
|
||||
}
|
||||
|
||||
SSDataBlock* pResBlock = pReader->pResBlock;
|
||||
if (pResBlock->pBlockAgg == NULL) {
|
||||
size_t num = taosArrayGetSize(pResBlock->pDataBlock);
|
||||
pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg));
|
||||
}
|
||||
#else
|
||||
|
||||
// fill the all null data column
|
||||
SArray* pNewAggList = taosArrayInit(numOfCols, sizeof(SColumnDataAgg));
|
||||
|
||||
while (j < numOfCols && i < size) {
|
||||
SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i);
|
||||
if (pAgg->colId == pSup->colIds[j]) {
|
||||
taosArrayPush(pNewAggList, pAgg);
|
||||
if (pAgg->colId == pSup->colId[j]) {
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = pAgg;
|
||||
i += 1;
|
||||
j += 1;
|
||||
} else if (pAgg->colId < pSup->colIds[j]) {
|
||||
} else if (pAgg->colId < pSup->colId[j]) {
|
||||
i += 1;
|
||||
} else if (pSup->colIds[j] < pAgg->colId) {
|
||||
if (pSup->colIds[j] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
taosArrayPush(pNewAggList, &pSup->tsColAgg);
|
||||
} else if (pSup->colId[j] < pAgg->colId) {
|
||||
if (pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg;
|
||||
} else {
|
||||
// all date in this block are null
|
||||
SColumnDataAgg nullColAgg = {.colId = pSup->colIds[j], .numOfNull = pBlock->nRow};
|
||||
taosArrayPush(pNewAggList, &nullColAgg);
|
||||
SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = pBlock->nRow};
|
||||
taosArrayPush(pSup->pColAgg, &nullColAgg);
|
||||
|
||||
pResBlock->pBlockAgg[pSup->slotId[j]] = taosArrayGetLast(pSup->pColAgg);
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayClear(pSup->pColAgg);
|
||||
taosArrayAddAll(pSup->pColAgg, pNewAggList);
|
||||
|
||||
size_t num = taosArrayGetSize(pSup->pColAgg);
|
||||
for(int32_t k = 0; k < num; ++k) {
|
||||
pSup->plist[k] = taosArrayGet(pSup->pColAgg, k);
|
||||
}
|
||||
|
||||
taosArrayDestroy(pNewAggList);
|
||||
|
||||
#endif
|
||||
|
||||
*pBlockSMA = pResBlock->pBlockAgg;
|
||||
pReader->cost.smaDataLoad += 1;
|
||||
*pBlockStatis = pSup->plist;
|
||||
|
||||
tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", %s", 0, pFBlock->uid, pReader->idStr);
|
||||
return code;
|
||||
}
|
||||
|
||||
static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
|
||||
static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) {
|
||||
SReaderStatus* pStatus = &pReader->status;
|
||||
|
||||
if (pStatus->composedDataBlock) {
|
||||
return pReader->pResBlock->pDataBlock;
|
||||
return pReader->pResBlock;
|
||||
}
|
||||
|
||||
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter);
|
||||
|
@ -4179,10 +4164,10 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
||||
return pReader->pResBlock->pDataBlock;
|
||||
return pReader->pResBlock;
|
||||
}
|
||||
|
||||
SArray* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
|
||||
SSDataBlock* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) {
|
||||
if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||
return doRetrieveDataBlock(pReader->innerReader[0]);
|
||||
|
@ -4209,7 +4194,6 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
|
|||
|
||||
// allocate buffer in order to load data blocks from file
|
||||
memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg));
|
||||
memset(pReader->suppInfo.plist, 0, POINTER_BYTES);
|
||||
|
||||
pReader->suppInfo.tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID;
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
|
|
|
@ -750,7 +750,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
// head
|
||||
tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
|
||||
tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -771,7 +771,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
// data
|
||||
tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
|
||||
tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -781,7 +781,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
}
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, LOGIC_TO_FILE_OFFSET(pSetFrom->pDataF->size, szPage));
|
||||
n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->pDataF->size, szPage));
|
||||
if (n < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -792,7 +792,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
// sma
|
||||
tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
|
||||
tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -814,7 +814,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
|
|||
for (int8_t iStt = 0; iStt < pSetFrom->nSttF; iStt++) {
|
||||
tsdbSttFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSttF[iStt], fNameFrom);
|
||||
tsdbSttFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSttF[iStt], fNameTo);
|
||||
pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
|
||||
if (pOutFD == NULL) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
goto _err;
|
||||
|
@ -1477,9 +1477,8 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
|||
}
|
||||
taosMemoryFree(pReader);
|
||||
}
|
||||
*ppReader = NULL;
|
||||
|
||||
_exit:
|
||||
*ppReader = NULL;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ int32_t tMapDataToArray(SMapData *pMapData, int32_t itemSize, int32_t (*tGetItem
|
|||
|
||||
SArray *pArray = taosArrayInit(pMapData->nItem, itemSize);
|
||||
if (pArray == NULL) {
|
||||
code = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
*/
|
||||
|
||||
#include "vnd.h"
|
||||
#include "vnodeInt.h"
|
||||
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME "vnode.json"
|
||||
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
|
||||
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
||||
static int vnodeCommitImpl(void *arg);
|
||||
static void vnodeWaitCommit(SVnode *pVnode);
|
||||
static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData);
|
||||
static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo);
|
||||
static int vnodeCommitImpl(SCommitInfo *pInfo);
|
||||
|
||||
int vnodeBegin(SVnode *pVnode) {
|
||||
// alloc buffer pool
|
||||
|
@ -107,7 +107,8 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
|
|||
// free info binary
|
||||
taosMemoryFree(data);
|
||||
|
||||
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum);
|
||||
vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname,
|
||||
pInfo->config.syncCfg.replicaNum);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -185,29 +186,78 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void vnodePrepareCommit(SVnode *pVnode) {
|
||||
tsem_wait(&pVnode->canCommit);
|
||||
|
||||
tsdbPrepareCommit(pVnode->pTsdb);
|
||||
metaPrepareAsyncCommit(pVnode->pMeta);
|
||||
smaPrepareAsyncCommit(pVnode->pSma);
|
||||
|
||||
|
||||
vnodeBufPoolUnRef(pVnode->inUse);
|
||||
pVnode->inUse = NULL;
|
||||
}
|
||||
static int32_t vnodeCommitTask(void *arg) {
|
||||
int32_t code = 0;
|
||||
|
||||
SCommitInfo *pInfo = (SCommitInfo *)arg;
|
||||
|
||||
// commit
|
||||
code = vnodeCommitImpl(pInfo);
|
||||
if (code) goto _exit;
|
||||
|
||||
// end commit
|
||||
tsem_post(&pInfo->pVnode->canCommit);
|
||||
|
||||
_exit:
|
||||
taosMemoryFree(pInfo);
|
||||
return code;
|
||||
}
|
||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||
vnodeWaitCommit(pVnode);
|
||||
int32_t code = 0;
|
||||
|
||||
// vnodeBufPoolSwitch(pVnode);
|
||||
// tsdbPrepareCommit(pVnode->pTsdb);
|
||||
// prepare to commit
|
||||
vnodePrepareCommit(pVnode);
|
||||
|
||||
vnodeScheduleTask(vnodeCommitImpl, pVnode);
|
||||
// schedule the task
|
||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||
|
||||
return 0;
|
||||
SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo));
|
||||
if (NULL == pInfo) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
pInfo->info.config = pVnode->config;
|
||||
pInfo->info.state.committed = pVnode->state.applied;
|
||||
pInfo->info.state.commitTerm = pVnode->state.applyTerm;
|
||||
pInfo->info.state.commitID = pVnode->state.commitID;
|
||||
pInfo->pVnode = pVnode;
|
||||
pInfo->txn = metaGetTxn(pVnode->pMeta);
|
||||
vnodeScheduleTask(vnodeCommitTask, pInfo);
|
||||
|
||||
_exit:
|
||||
if (code) {
|
||||
vError("vgId:%d %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code),
|
||||
pVnode->state.commitID);
|
||||
} else {
|
||||
vDebug("vgId:%d %s done", TD_VID(pVnode), __func__);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int vnodeSyncCommit(SVnode *pVnode) {
|
||||
vnodeAsyncCommit(pVnode);
|
||||
vnodeWaitCommit(pVnode);
|
||||
tsem_post(&(pVnode->canCommit));
|
||||
tsem_wait(&pVnode->canCommit);
|
||||
tsem_post(&pVnode->canCommit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vnodeCommit(SVnode *pVnode) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SVnodeInfo info = {0};
|
||||
char dir[TSDB_FILENAME_LEN];
|
||||
static int vnodeCommitImpl(SCommitInfo *pInfo) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
|
||||
char dir[TSDB_FILENAME_LEN] = {0};
|
||||
SVnode *pVnode = pInfo->pVnode;
|
||||
|
||||
vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode),
|
||||
pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm);
|
||||
|
@ -218,19 +268,13 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
pVnode->state.commitTerm = pVnode->state.applyTerm;
|
||||
|
||||
// save info
|
||||
info.config = pVnode->config;
|
||||
info.state.committed = pVnode->state.applied;
|
||||
info.state.commitTerm = pVnode->state.applyTerm;
|
||||
info.state.commitID = pVnode->state.commitID;
|
||||
if (pVnode->pTfs) {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
|
||||
} else {
|
||||
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
|
||||
}
|
||||
if (vnodeSaveInfo(dir, &info) < 0) {
|
||||
if (vnodeSaveInfo(dir, &pInfo->info) < 0) {
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
@ -238,23 +282,17 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
|
||||
syncBeginSnapshot(pVnode->sync, pVnode->state.applied);
|
||||
|
||||
code = smaPreCommit(pVnode->pSma);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
vnodeBufPoolUnRef(pVnode->inUse);
|
||||
pVnode->inUse = NULL;
|
||||
|
||||
// commit each sub-system
|
||||
if (metaCommit(pVnode->pMeta) < 0) {
|
||||
if (metaCommit(pVnode->pMeta, pInfo->txn) < 0) {
|
||||
code = TSDB_CODE_FAILED;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
code = tsdbCommit(pVnode->pTsdb);
|
||||
code = tsdbCommit(pVnode->pTsdb, pInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
if (VND_IS_RSMA(pVnode)) {
|
||||
code = smaCommit(pVnode->pSma);
|
||||
code = smaCommit(pVnode->pSma, pInfo);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
|
@ -264,7 +302,7 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
}
|
||||
|
||||
// commit info
|
||||
if (vnodeCommitInfo(dir, &info) < 0) {
|
||||
if (vnodeCommitInfo(dir, &pInfo->info) < 0) {
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
@ -277,19 +315,18 @@ int vnodeCommit(SVnode *pVnode) {
|
|||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
if (metaFinishCommit(pVnode->pMeta) < 0) {
|
||||
if (metaFinishCommit(pVnode->pMeta, pInfo->txn) < 0) {
|
||||
code = terrno;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
|
||||
pVnode->state.committed = info.state.committed;
|
||||
pVnode->state.committed = pInfo->info.state.committed;
|
||||
|
||||
if (smaPostCommit(pVnode->pSma) < 0) {
|
||||
vError("vgId:%d, failed to post-commit sma since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// apply the commit (TODO)
|
||||
// walEndSnapshot(pVnode->pWal);
|
||||
syncEndSnapshot(pVnode->sync);
|
||||
|
||||
|
@ -318,20 +355,6 @@ void vnodeRollback(SVnode *pVnode) {
|
|||
(void)taosRemoveFile(tFName);
|
||||
}
|
||||
|
||||
static int vnodeCommitImpl(void *arg) {
|
||||
SVnode *pVnode = (SVnode *)arg;
|
||||
|
||||
// metaCommit(pVnode->pMeta);
|
||||
tqCommit(pVnode->pTq);
|
||||
// tsdbCommit(pVnode->pTsdb, );
|
||||
|
||||
// vnodeBufPoolRecycle(pVnode);
|
||||
tsem_post(&(pVnode->canCommit));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); }
|
||||
|
||||
static int vnodeEncodeState(const void *pObj, SJson *pJson) {
|
||||
const SVState *pState = (SVState *)pObj;
|
||||
|
||||
|
|
|
@ -242,14 +242,14 @@ _err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void vnodePreClose(SVnode *pVnode) {
|
||||
void vnodePreClose(SVnode *pVnode) {
|
||||
vnodeQueryPreClose(pVnode);
|
||||
vnodeSyncPreClose(pVnode);
|
||||
vnodeSyncPreClose(pVnode);
|
||||
}
|
||||
|
||||
void vnodeClose(SVnode *pVnode) {
|
||||
if (pVnode) {
|
||||
vnodeCommit(pVnode);
|
||||
vnodeSyncCommit(pVnode);
|
||||
vnodeSyncClose(pVnode);
|
||||
vnodeQueryClose(pVnode);
|
||||
walClose(pVnode->pWal);
|
||||
|
|
|
@ -259,7 +259,7 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
|||
pWriter->ever = ever;
|
||||
|
||||
// commit it
|
||||
code = vnodeCommit(pVnode);
|
||||
code = vnodeSyncCommit(pVnode);
|
||||
if (code) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
|
|
|
@ -181,14 +181,15 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
if (version <= pVnode->state.applied) {
|
||||
vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version,
|
||||
pVnode->state.applied);
|
||||
terrno = TSDB_CODE_VND_DUP_REQUEST;
|
||||
pRsp->info.handle = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
vDebug("vgId:%d, start to process write request %s, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||
version);
|
||||
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
||||
|
||||
ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm);
|
||||
pVnode->state.applied = version;
|
||||
pVnode->state.applyTerm = pMsg->info.conn.applyTerm;
|
||||
|
||||
|
@ -291,7 +292,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
vnodeProcessAlterConfigReq(pVnode, version, pReq, len, pRsp);
|
||||
break;
|
||||
case TDMT_VND_COMMIT:
|
||||
goto _do_commit;
|
||||
vnodeSyncCommit(pVnode);
|
||||
vnodeBegin(pVnode);
|
||||
goto _exit;
|
||||
default:
|
||||
vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType);
|
||||
return -1;
|
||||
|
@ -309,13 +312,12 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
|
||||
// commit if need
|
||||
if (vnodeShouldCommit(pVnode)) {
|
||||
_do_commit:
|
||||
vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version);
|
||||
// commit current change
|
||||
if (vnodeCommit(pVnode) < 0) {
|
||||
vError("vgId:%d, failed to commit vnode since %s.", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
}
|
||||
#if 0
|
||||
vnodeSyncCommit(pVnode);
|
||||
#else
|
||||
vnodeAsyncCommit(pVnode);
|
||||
#endif
|
||||
|
||||
// start a new one
|
||||
if (vnodeBegin(pVnode) < 0) {
|
||||
|
@ -324,6 +326,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
|
|||
}
|
||||
}
|
||||
|
||||
_exit:
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
|
@ -344,7 +347,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
vTrace("message in vnode query queue is processing");
|
||||
// if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsLeader(pVnode)) {
|
||||
if ((pMsg->msgType == TDMT_SCH_QUERY) && !syncIsReadyForRead(pVnode->sync)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, terrno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -367,12 +370,12 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
pMsg->msgType == TDMT_VND_BATCH_META) &&
|
||||
!syncIsReadyForRead(pVnode->sync)) {
|
||||
// !vnodeIsLeader(pVnode)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, terrno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pMsg->msgType == TDMT_VND_TMQ_CONSUME && !pVnode->restored) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, TSDB_CODE_SYN_RESTORING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,16 +16,17 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "vnd.h"
|
||||
|
||||
#define BATCH_DISABLE 1
|
||||
|
||||
static inline bool vnodeIsMsgBlock(tmsg_t type) {
|
||||
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||
|
||||
(type == TDMT_VND_UPDATE_TAG_VAL);
|
||||
}
|
||||
#define BATCH_ENABLE 0
|
||||
|
||||
static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; }
|
||||
|
||||
static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType));
|
||||
tsem_wait(&pVnode->syncSem);
|
||||
}
|
||||
|
||||
static inline void vnodeWaitBlockMsgOld(SVnode *pVnode, const SRpcMsg *pMsg) {
|
||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
|
@ -53,7 +54,7 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) {
|
||||
SEpSet newEpSet = {0};
|
||||
syncGetRetryEpSet(pVnode->sync, &newEpSet);
|
||||
|
||||
|
@ -66,8 +67,20 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
pMsg->info.hasEpSet = 1;
|
||||
|
||||
SRpcMsg rsp = {.code = TSDB_CODE_SYN_NOT_LEADER, .info = pMsg->info, .msgType = pMsg->msgType + 1};
|
||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||
if (code == 0) code = TSDB_CODE_SYN_NOT_LEADER;
|
||||
|
||||
SRpcMsg rsp = {.code = code, .info = pMsg->info, .msgType = pMsg->msgType + 1};
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &newEpSet);
|
||||
|
||||
rsp.pCont = rpcMallocCont(contLen);
|
||||
if (rsp.pCont == NULL) {
|
||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
tSerializeSEpSet(rsp.pCont, contLen, &newEpSet);
|
||||
rsp.contLen = contLen;
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
||||
static void inline vnodeHandleWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
|
@ -87,8 +100,8 @@ static void inline vnodeHandleWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
}
|
||||
|
||||
static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) {
|
||||
if (code == TSDB_CODE_SYN_NOT_LEADER) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg, code);
|
||||
} else {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", pVnode->config.vgId, pMsg, tstrerror(code), code);
|
||||
|
@ -99,28 +112,35 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code)
|
|||
}
|
||||
}
|
||||
|
||||
#if BATCH_ENABLE
|
||||
|
||||
static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) {
|
||||
if (*arrSize <= 0) return;
|
||||
SRpcMsg *pLastMsg = pMsgArr[*arrSize - 1];
|
||||
|
||||
#if BATCH_DISABLE
|
||||
int32_t code = syncPropose(pVnode->sync, pMsgArr[0], pIsWeakArr[0]);
|
||||
#else
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize);
|
||||
#endif
|
||||
bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType));
|
||||
if (wait) {
|
||||
ASSERT(!pVnode->blocked);
|
||||
pVnode->blocked = true;
|
||||
}
|
||||
taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
||||
if (code > 0) {
|
||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||
vnodeHandleWriteMsg(pVnode, pMsgArr[i]);
|
||||
}
|
||||
} else if (code == 0) {
|
||||
vnodeWaitBlockMsg(pVnode, pMsgArr[*arrSize - 1]);
|
||||
} else {
|
||||
} else if (code < 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||
vnodeHandleProposeError(pVnode, pMsgArr[i], code);
|
||||
}
|
||||
}
|
||||
|
||||
if (wait) vnodeWaitBlockMsg(pVnode, pLastMsg);
|
||||
pLastMsg = NULL;
|
||||
|
||||
for (int32_t i = 0; i < *arrSize; ++i) {
|
||||
SRpcMsg *pMsg = pMsgArr[i];
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
|
@ -177,7 +197,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isBlock || BATCH_DISABLE) {
|
||||
if (isBlock) {
|
||||
vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos);
|
||||
}
|
||||
|
||||
|
@ -185,7 +205,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
|||
pIsWeakArr[arrayPos] = isWeak;
|
||||
arrayPos++;
|
||||
|
||||
if (isBlock || msg == numOfMsgs - 1 || BATCH_DISABLE) {
|
||||
if (isBlock || msg == numOfMsgs - 1) {
|
||||
vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos);
|
||||
}
|
||||
}
|
||||
|
@ -194,6 +214,72 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
|
|||
taosMemoryFree(pIsWeakArr);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) {
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
int32_t code = syncPropose(pVnode->sync, pMsg, isWeak);
|
||||
bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType));
|
||||
if (wait) {
|
||||
ASSERT(!pVnode->blocked);
|
||||
pVnode->blocked = true;
|
||||
}
|
||||
taosThreadMutexUnlock(&pVnode->lock);
|
||||
|
||||
if (code > 0) {
|
||||
vnodeHandleWriteMsg(pVnode, pMsg);
|
||||
} else if (code < 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
vnodeHandleProposeError(pVnode, pMsg, code);
|
||||
}
|
||||
|
||||
if (wait) vnodeWaitBlockMsg(pVnode, pMsg);
|
||||
return code;
|
||||
}
|
||||
|
||||
void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnode *pVnode = pInfo->ahandle;
|
||||
int32_t vgId = pVnode->config.vgId;
|
||||
int32_t code = 0;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
vTrace("vgId:%d, get %d msgs from vnode-write queue", vgId, numOfMsgs);
|
||||
|
||||
for (int32_t msg = 0; msg < numOfMsgs; msg++) {
|
||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||
bool isWeak = vnodeIsMsgWeak(pMsg->msgType);
|
||||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, msg:%p get from vnode-write queue, weak:%d block:%d msg:%d:%d, handle:%p", vgId, pMsg, isWeak,
|
||||
vnodeIsMsgBlock(pMsg->msgType), msg, numOfMsgs, pMsg->info.handle);
|
||||
|
||||
if (!pVnode->restored) {
|
||||
vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg);
|
||||
vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_SYN_RESTORING);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
code = vnodePreProcessWriteMsg(pVnode, pMsg);
|
||||
if (code != 0) {
|
||||
vGError("vgId:%d, msg:%p failed to pre-process since %s", vgId, pMsg, terrstr());
|
||||
if (terrno != 0) code = terrno;
|
||||
vnodeHandleProposeError(pVnode, pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
continue;
|
||||
}
|
||||
|
||||
code = vnodeProposeMsg(pVnode, pMsg, isWeak);
|
||||
|
||||
vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnode *pVnode = pInfo->ahandle;
|
||||
int32_t vgId = pVnode->config.vgId;
|
||||
|
@ -206,6 +292,11 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
|||
vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg,
|
||||
TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex);
|
||||
|
||||
if (vnodeIsMsgBlock(pMsg->msgType)) {
|
||||
vTrace("vgId:%d, blocking msg obtained from apply-queue. index:%" PRId64 ", term: %" PRId64 ", type: %s", vgId,
|
||||
pMsg->info.conn.applyIndex, pMsg->info.conn.applyTerm, TMSG_INFO(pMsg->msgType));
|
||||
}
|
||||
|
||||
SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info};
|
||||
if (rsp.code == 0) {
|
||||
if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) {
|
||||
|
@ -295,7 +386,7 @@ static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
pMsg->info.conn.applyIndex = pMeta->index;
|
||||
pMsg->info.conn.applyTerm = pMeta->term;
|
||||
|
@ -306,17 +397,18 @@ static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbM
|
|||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code,
|
||||
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg);
|
||||
return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg);
|
||||
}
|
||||
|
||||
static void vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
static int32_t vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
return vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
|
||||
static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
static int32_t vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
if (pMeta->isWeak == 1) {
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
return vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
|
|
|
@ -762,7 +762,6 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput)
|
|||
int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList);
|
||||
void ctgFreeJob(void* job);
|
||||
void ctgFreeHandleImpl(SCatalog* pCtg);
|
||||
void ctgFreeVgInfo(SDBVgInfo* vgInfo);
|
||||
int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup);
|
||||
int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx,
|
||||
char* dbFName, SArray* pNames, bool update);
|
||||
|
@ -789,6 +788,8 @@ int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName);
|
|||
int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||
SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch);
|
||||
int32_t ctgdGetOneHandle(SCatalog **pHandle);
|
||||
int ctgVgInfoComp(const void* lp, const void* rp);
|
||||
int32_t ctgMakeVgArray(SDBVgInfo* dbInfo);
|
||||
|
||||
extern SCatalogMgmt gCtgMgmt;
|
||||
extern SCtgDebug gCTGDebug;
|
||||
|
|
|
@ -505,8 +505,7 @@ _return:
|
|||
taosMemoryFreeClear(tbMeta);
|
||||
|
||||
if (vgInfo) {
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
taosMemoryFreeClear(vgInfo);
|
||||
freeVgInfo(vgInfo);
|
||||
}
|
||||
|
||||
if (vgList) {
|
||||
|
@ -546,8 +545,7 @@ _return:
|
|||
}
|
||||
|
||||
if (vgInfo) {
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
taosMemoryFreeClear(vgInfo);
|
||||
freeVgInfo(vgInfo);
|
||||
}
|
||||
|
||||
CTG_RET(code);
|
||||
|
@ -619,7 +617,7 @@ int32_t catalogInit(SCatalogCfg* cfg) {
|
|||
gCtgMgmt.queue.head = taosMemoryCalloc(1, sizeof(SCtgQNode));
|
||||
if (NULL == gCtgMgmt.queue.head) {
|
||||
qError("calloc %d failed", (int32_t)sizeof(SCtgQNode));
|
||||
CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
gCtgMgmt.queue.tail = gCtgMgmt.queue.head;
|
||||
|
||||
|
@ -778,8 +776,7 @@ _return:
|
|||
}
|
||||
|
||||
if (vgInfo) {
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
taosMemoryFreeClear(vgInfo);
|
||||
freeVgInfo(vgInfo);
|
||||
}
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
|
@ -836,8 +833,7 @@ _return:
|
|||
ctgRUnlockVgInfo(dbCache);
|
||||
ctgReleaseDBCache(pCtg, dbCache);
|
||||
} else if (dbInfo) {
|
||||
taosHashCleanup(dbInfo->vgHash);
|
||||
taosMemoryFreeClear(dbInfo);
|
||||
freeVgInfo(dbInfo);
|
||||
}
|
||||
|
||||
CTG_API_LEAVE(code);
|
||||
|
@ -849,7 +845,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId
|
|||
int32_t code = 0;
|
||||
|
||||
if (NULL == pCtg || NULL == dbFName || NULL == dbInfo) {
|
||||
ctgFreeVgInfo(dbInfo);
|
||||
freeVgInfo(dbInfo);
|
||||
CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
|
|
|
@ -226,6 +226,7 @@ _return:
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
||||
SCtgDBCache *dbCache = NULL;
|
||||
SCtgTbCache *pCache = NULL;
|
||||
|
@ -276,6 +277,49 @@ _return:
|
|||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
int32_t ctgAcquireStbMetaFromCache(SCtgDBCache *dbCache, SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgTbCache **pTb) {
|
||||
SCtgTbCache *pCache = NULL;
|
||||
char *stName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid));
|
||||
if (NULL == stName) {
|
||||
ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
pCache = taosHashAcquire(dbCache->tbCache, stName, strlen(stName));
|
||||
if (NULL == pCache) {
|
||||
ctgDebug("stb 0x%" PRIx64 " name %s not in cache, dbFName:%s", suid, stName, dbFName);
|
||||
taosHashRelease(dbCache->stbCache, stName);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
taosHashRelease(dbCache->stbCache, stName);
|
||||
|
||||
CTG_LOCK(CTG_READ, &pCache->metaLock);
|
||||
if (NULL == pCache->pMeta) {
|
||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", suid, dbFName);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
*pTb = pCache;
|
||||
|
||||
ctgDebug("stb 0x%" PRIx64 " meta got in cache, dbFName:%s", suid, dbFName);
|
||||
|
||||
CTG_CACHE_STAT_INC(numOfMetaHit, 1);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||
|
||||
CTG_CACHE_STAT_INC(numOfMetaMiss, 1);
|
||||
|
||||
*pTb = NULL;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgAcquireTbIndexFromCache(SCatalog *pCtg, char *dbFName, char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) {
|
||||
SCtgDBCache *dbCache = NULL;
|
||||
|
@ -384,13 +428,19 @@ int32_t ctgReadTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta **
|
|||
|
||||
memcpy(*pTableMeta, tbMeta, metaSize);
|
||||
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
|
||||
if (tbCache) {
|
||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, tbCache);
|
||||
}
|
||||
|
||||
ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s", ctx->pName->tname,
|
||||
ctx->tbInfo.tbType, dbFName);
|
||||
|
||||
ctgAcquireStbMetaFromCache(pCtg, dbFName, ctx->tbInfo.suid, &dbCache, &tbCache);
|
||||
ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, ctx->tbInfo.suid, &tbCache);
|
||||
if (NULL == tbCache) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
taosMemoryFreeClear(*pTableMeta);
|
||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache", ctx->tbInfo.suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -460,12 +510,17 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver,
|
|||
|
||||
// PROCESS FOR CHILD TABLE
|
||||
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
if (tbCache) {
|
||||
CTG_UNLOCK(CTG_READ, &tbCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, tbCache);
|
||||
}
|
||||
|
||||
ctgDebug("Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s", pTableName->tname, dbFName);
|
||||
|
||||
ctgAcquireStbMetaFromCache(pCtg, dbFName, *suid, &dbCache, &tbCache);
|
||||
ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, *suid, &tbCache);
|
||||
if (NULL == tbCache) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
//ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache);
|
||||
ctgDebug("stb 0x%" PRIx64 " meta not in cache", *suid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -794,7 +849,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
|||
if (NULL == msg) {
|
||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateVgMsg));
|
||||
taosMemoryFree(op);
|
||||
ctgFreeVgInfo(dbInfo);
|
||||
freeVgInfo(dbInfo);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -803,6 +858,14 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
|||
dbFName = p + 1;
|
||||
}
|
||||
|
||||
code = ctgMakeVgArray(dbInfo);
|
||||
if (code) {
|
||||
taosMemoryFree(op);
|
||||
taosMemoryFree(msg);
|
||||
freeVgInfo(dbInfo);
|
||||
CTG_ERR_RET(code);
|
||||
}
|
||||
|
||||
tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||
msg->pCtg = pCtg;
|
||||
msg->dbId = dbId;
|
||||
|
@ -816,7 +879,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId
|
|||
|
||||
_return:
|
||||
|
||||
ctgFreeVgInfo(dbInfo);
|
||||
freeVgInfo(dbInfo);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
@ -1549,6 +1612,20 @@ void ctgFreeAllInstance(void) {
|
|||
taosHashClear(gCtgMgmt.pCluster);
|
||||
}
|
||||
|
||||
int32_t ctgVgInfoIdComp(void const* lp, void const* rp) {
|
||||
int32_t* key = (int32_t*)lp;
|
||||
SVgroupInfo* pVg = (SVgroupInfo*)rp;
|
||||
|
||||
if (*key < pVg->vgId) {
|
||||
return -1;
|
||||
} else if (*key > pVg->vgId) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
||||
int32_t code = 0;
|
||||
SCtgUpdateVgMsg *msg = operation->data;
|
||||
|
@ -1600,7 +1677,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
|||
goto _return;
|
||||
}
|
||||
|
||||
ctgFreeVgInfo(vgInfo);
|
||||
freeVgInfo(vgInfo);
|
||||
}
|
||||
|
||||
vgCache->vgInfo = dbInfo;
|
||||
|
@ -1621,7 +1698,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) {
|
|||
|
||||
_return:
|
||||
|
||||
ctgFreeVgInfo(msg->dbInfo);
|
||||
freeVgInfo(msg->dbInfo);
|
||||
taosMemoryFreeClear(msg);
|
||||
|
||||
CTG_RET(code);
|
||||
|
@ -1674,7 +1751,7 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
|
|||
|
||||
CTG_ERR_JRET(ctgWLockVgInfo(pCtg, dbCache));
|
||||
|
||||
ctgFreeVgInfo(dbCache->vgCache.vgInfo);
|
||||
freeVgInfo(dbCache->vgCache.vgInfo);
|
||||
dbCache->vgCache.vgInfo = NULL;
|
||||
|
||||
ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName);
|
||||
|
@ -1930,7 +2007,13 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
|||
|
||||
SVgroupInfo *pInfo = taosHashGet(vgInfo->vgHash, &msg->vgId, sizeof(msg->vgId));
|
||||
if (NULL == pInfo) {
|
||||
ctgDebug("no vgroup %d in db %s, ignore epset update", msg->vgId, msg->dbFName);
|
||||
ctgDebug("no vgroup %d in db %s vgHash, ignore epset update", msg->vgId, msg->dbFName);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
SVgroupInfo *pInfo2 = taosArraySearch(vgInfo->vgArray, &msg->vgId, ctgVgInfoIdComp, TD_EQ);
|
||||
if (NULL == pInfo2) {
|
||||
ctgDebug("no vgroup %d in db %s vgArray, ignore epset update", msg->vgId, msg->dbFName);
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -1941,6 +2024,7 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) {
|
|||
msg->epSet.numOfEps, pNewEp->fqdn, pNewEp->port, msg->dbFName);
|
||||
|
||||
pInfo->epSet = msg->epSet;
|
||||
pInfo2->epSet = msg->epSet;
|
||||
|
||||
_return:
|
||||
|
||||
|
@ -2057,7 +2141,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) {
|
|||
switch (op->opId) {
|
||||
case CTG_OP_UPDATE_VGROUP: {
|
||||
SCtgUpdateVgMsg *msg = op->data;
|
||||
ctgFreeVgInfo(msg->dbInfo);
|
||||
freeVgInfo(msg->dbInfo);
|
||||
taosMemoryFreeClear(op->data);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -384,13 +384,13 @@ int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, SArr
|
|||
SMsgSendInfo* msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == msgSendInfo) {
|
||||
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||
CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SCtgTaskCallbackParam* param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam));
|
||||
if (NULL == param) {
|
||||
qError("calloc %d failed", (int32_t)sizeof(SCtgTaskCallbackParam));
|
||||
CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
param->reqType = msgType;
|
||||
|
|
|
@ -231,20 +231,7 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) {
|
|||
CTG_CACHE_STAT_DEC(numOfTbl, tblNum);
|
||||
}
|
||||
|
||||
void ctgFreeVgInfo(SDBVgInfo* vgInfo) {
|
||||
if (NULL == vgInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vgInfo->vgHash) {
|
||||
taosHashCleanup(vgInfo->vgHash);
|
||||
vgInfo->vgHash = NULL;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(vgInfo);
|
||||
}
|
||||
|
||||
void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { ctgFreeVgInfo(dbCache->vgCache.vgInfo); }
|
||||
void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { freeVgInfo(dbCache->vgCache.vgInfo); }
|
||||
|
||||
void ctgFreeDbCache(SCtgDBCache* dbCache) {
|
||||
if (NULL == dbCache) {
|
||||
|
@ -366,8 +353,7 @@ void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) {
|
|||
}
|
||||
|
||||
if (pOutput->dbVgroup) {
|
||||
taosHashCleanup(pOutput->dbVgroup->vgHash);
|
||||
taosMemoryFreeClear(pOutput->dbVgroup);
|
||||
freeVgInfo(pOutput->dbVgroup);
|
||||
}
|
||||
|
||||
taosMemoryFree(pOutput);
|
||||
|
@ -573,8 +559,7 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void** pRes) {
|
|||
case CTG_TASK_GET_DB_VGROUP: {
|
||||
if (*pRes) {
|
||||
SDBVgInfo* pInfo = (SDBVgInfo*)*pRes;
|
||||
taosHashCleanup(pInfo->vgHash);
|
||||
taosMemoryFreeClear(*pRes);
|
||||
freeVgInfo(pInfo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -837,10 +822,36 @@ _return:
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int ctgVgInfoComp(const void* lp, const void* rp) {
|
||||
SVgroupInfo* pLeft = (SVgroupInfo*)lp;
|
||||
SVgroupInfo* pRight = (SVgroupInfo*)rp;
|
||||
if (pLeft->hashBegin < pRight->hashBegin) {
|
||||
return -1;
|
||||
} else if (pLeft->hashBegin > pRight->hashBegin) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ctgHashValueComp(void const* lp, void const* rp) {
|
||||
uint32_t* key = (uint32_t*)lp;
|
||||
SVgroupInfo* pVg = (SVgroupInfo*)rp;
|
||||
|
||||
if (*key < pVg->hashBegin) {
|
||||
return -1;
|
||||
} else if (*key > pVg->hashEnd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup) {
|
||||
int32_t code = 0;
|
||||
CTG_ERR_RET(ctgMakeVgArray(dbInfo));
|
||||
|
||||
int32_t vgNum = taosHashGetSize(dbInfo->vgHash);
|
||||
int32_t vgNum = taosArrayGetSize(dbInfo->vgArray);
|
||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(pTableName, db);
|
||||
|
||||
|
@ -856,6 +867,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName
|
|||
uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod,
|
||||
dbInfo->hashPrefix, dbInfo->hashSuffix);
|
||||
|
||||
vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ);
|
||||
|
||||
/*
|
||||
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
while (pIter) {
|
||||
vgInfo = pIter;
|
||||
|
@ -867,10 +881,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName
|
|||
pIter = taosHashIterate(dbInfo->vgHash, pIter);
|
||||
vgInfo = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
if (NULL == vgInfo) {
|
||||
ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db,
|
||||
taosHashGetSize(dbInfo->vgHash));
|
||||
(int32_t)taosArrayGetSize(dbInfo->vgArray));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
@ -883,37 +898,15 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName
|
|||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgHashValueComp(void const* lp, void const* rp) {
|
||||
uint32_t* key = (uint32_t*)lp;
|
||||
SVgroupInfo* pVg = *(SVgroupInfo**)rp;
|
||||
|
||||
if (*key < pVg->hashBegin) {
|
||||
return -1;
|
||||
} else if (*key > pVg->hashEnd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ctgVgInfoComp(const void* lp, const void* rp) {
|
||||
SVgroupInfo* pLeft = *(SVgroupInfo**)lp;
|
||||
SVgroupInfo* pRight = *(SVgroupInfo**)rp;
|
||||
if (pLeft->hashBegin < pRight->hashBegin) {
|
||||
return -1;
|
||||
} else if (pLeft->hashBegin > pRight->hashBegin) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx,
|
||||
char* dbFName, SArray* pNames, bool update) {
|
||||
int32_t code = 0;
|
||||
SCtgTask* pTask = tReq->pTask;
|
||||
SMetaRes res = {0};
|
||||
int32_t vgNum = taosHashGetSize(dbInfo->vgHash);
|
||||
|
||||
CTG_ERR_RET(ctgMakeVgArray(dbInfo));
|
||||
|
||||
int32_t vgNum = taosArrayGetSize(dbInfo->vgArray);
|
||||
if (vgNum <= 0) {
|
||||
ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
|
@ -923,20 +916,13 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
|
|||
int32_t tbNum = taosArrayGetSize(pNames);
|
||||
|
||||
if (1 == vgNum) {
|
||||
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
if (NULL == pIter) {
|
||||
ctgError("empty vgHash, db:%s, vgroup number:%d", dbFName, vgNum);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < tbNum; ++i) {
|
||||
vgInfo = taosMemoryMalloc(sizeof(SVgroupInfo));
|
||||
if (NULL == vgInfo) {
|
||||
taosHashCancelIterate(dbInfo->vgHash, pIter);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
*vgInfo = *(SVgroupInfo*)pIter;
|
||||
*vgInfo = *(SVgroupInfo*)taosArrayGet(dbInfo->vgArray, 0);
|
||||
|
||||
ctgDebug("Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d", vgInfo->vgId, vgInfo->epSet.numOfEps,
|
||||
vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port);
|
||||
|
@ -951,19 +937,9 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
|
|||
}
|
||||
}
|
||||
|
||||
taosHashCancelIterate(dbInfo->vgHash, pIter);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SArray* pVgList = taosArrayInit(vgNum, POINTER_BYTES);
|
||||
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
while (pIter) {
|
||||
taosArrayPush(pVgList, &pIter);
|
||||
pIter = taosHashIterate(dbInfo->vgHash, pIter);
|
||||
}
|
||||
|
||||
taosArraySort(pVgList, ctgVgInfoComp);
|
||||
|
||||
char tbFullName[TSDB_TABLE_FNAME_LEN];
|
||||
sprintf(tbFullName, "%s.", dbFName);
|
||||
int32_t offset = strlen(tbFullName);
|
||||
|
@ -979,20 +955,15 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
|
|||
uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod,
|
||||
dbInfo->hashPrefix, dbInfo->hashSuffix);
|
||||
|
||||
SVgroupInfo** p = taosArraySearch(pVgList, &hashValue, ctgHashValueComp, TD_EQ);
|
||||
|
||||
if (NULL == p) {
|
||||
vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ);
|
||||
if (NULL == vgInfo) {
|
||||
ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName,
|
||||
taosHashGetSize(dbInfo->vgHash));
|
||||
taosArrayDestroy(pVgList);
|
||||
(int32_t)taosArrayGetSize(dbInfo->vgArray));
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
vgInfo = *p;
|
||||
|
||||
SVgroupInfo* pNewVg = taosMemoryMalloc(sizeof(SVgroupInfo));
|
||||
if (NULL == pNewVg) {
|
||||
taosArrayDestroy(pVgList);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -1012,8 +983,6 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo*
|
|||
}
|
||||
}
|
||||
|
||||
taosArrayDestroy(pVgList);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1026,33 @@ int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) {
|
||||
if (NULL == dbInfo) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
if (dbInfo->vgHash && NULL == dbInfo->vgArray) {
|
||||
dbInfo->vgArray = taosArrayInit(100, sizeof(SVgroupInfo));
|
||||
if (NULL == dbInfo->vgArray) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
void* pIter = taosHashIterate(dbInfo->vgHash, NULL);
|
||||
while (pIter) {
|
||||
taosArrayPush(dbInfo->vgArray, pIter);
|
||||
pIter = taosHashIterate(dbInfo->vgHash, pIter);
|
||||
}
|
||||
|
||||
taosArraySort(dbInfo->vgArray, ctgVgInfoComp);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) {
|
||||
CTG_ERR_RET(ctgMakeVgArray(src));
|
||||
|
||||
*dst = taosMemoryMalloc(sizeof(SDBVgInfo));
|
||||
if (NULL == *dst) {
|
||||
qError("malloc %d failed", (int32_t)sizeof(SDBVgInfo));
|
||||
|
@ -1090,6 +1085,10 @@ int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) {
|
|||
pIter = taosHashIterate(src->vgHash, pIter);
|
||||
}
|
||||
|
||||
if (src->vgArray) {
|
||||
(*dst)->vgArray = taosArrayDup(src->vgArray, NULL);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe
|
|||
(*pRsp)->precision = 0;
|
||||
(*pRsp)->compressed = 0;
|
||||
(*pRsp)->compLen = 0;
|
||||
(*pRsp)->numOfRows = htonl(pBlock->info.rows);
|
||||
(*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||
(*pRsp)->numOfCols = htonl(numOfCols);
|
||||
|
||||
int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols);
|
||||
|
@ -497,7 +497,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
|
|||
SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1);
|
||||
char* buf2 = taosMemoryMalloc(SHOW_CREATE_TB_RESULT_FIELD2_LEN);
|
||||
if (NULL == buf2) {
|
||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,19 +77,19 @@ int32_t qExplainInitCtx(SExplainCtx **pCtx, SHashObj *groupHash, bool verbose, d
|
|||
SExplainCtx *ctx = taosMemoryCalloc(1, sizeof(SExplainCtx));
|
||||
if (NULL == ctx) {
|
||||
qError("calloc SExplainCtx failed");
|
||||
QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SArray *rows = taosArrayInit(10, sizeof(SQueryExplainRowInfo));
|
||||
if (NULL == rows) {
|
||||
qError("taosArrayInit SQueryExplainRowInfo failed");
|
||||
QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
char *tbuf = taosMemoryMalloc(TSDB_EXPLAIN_RESULT_ROW_SIZE);
|
||||
if (NULL == tbuf) {
|
||||
qError("malloc size %d failed", TSDB_EXPLAIN_RESULT_ROW_SIZE);
|
||||
QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ctx->mode = mode;
|
||||
|
@ -235,14 +235,14 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
|||
}
|
||||
default:
|
||||
qError("not supported physical node type %d", pNode->type);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (pPhysiChildren) {
|
||||
*pChildren = nodesMakeList();
|
||||
if (NULL == *pChildren) {
|
||||
qError("nodesMakeList failed");
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S
|
|||
*pExecInfo = taosArrayInit(group->nodeNum, sizeof(SExplainExecInfo));
|
||||
if (NULL == (*pExecInfo)) {
|
||||
qError("taosArrayInit %d explainExecInfo failed", group->nodeNum);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SExplainRsp *rsp = NULL;
|
||||
|
@ -272,7 +272,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S
|
|||
rsp = taosArrayGet(group->nodeExecInfo, group->nodeIdx++);
|
||||
if (group->physiPlanExecIdx >= rsp->numOfPlans) {
|
||||
qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx);
|
||||
|
@ -281,7 +281,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S
|
|||
rsp = taosArrayGet(group->nodeExecInfo, i);
|
||||
if (group->physiPlanExecIdx >= rsp->numOfPlans) {
|
||||
qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx);
|
||||
|
@ -297,13 +297,13 @@ int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplai
|
|||
if (NULL == pNode) {
|
||||
*pResNode = NULL;
|
||||
qError("physical node is NULL");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
SExplainResNode *resNode = taosMemoryCalloc(1, sizeof(SExplainResNode));
|
||||
if (NULL == resNode) {
|
||||
qError("calloc SPhysiNodeExplainRes failed");
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
|
@ -378,7 +378,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
|
|||
row.buf = taosMemoryMalloc(len);
|
||||
if (NULL == row.buf) {
|
||||
qError("taosMemoryMalloc %d failed", len);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
memcpy(row.buf, tbuf, len);
|
||||
|
@ -389,7 +389,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t
|
|||
if (NULL == taosArrayPush(ctx->rows, &row)) {
|
||||
qError("taosArrayPush row to explain res rows failed");
|
||||
taosMemoryFree(row.buf);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -407,7 +407,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
SPhysiNode *pNode = pResNode->pNode;
|
||||
if (NULL == pNode) {
|
||||
qError("pyhsical node in explain res node is NULL");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
switch (pNode->type) {
|
||||
|
@ -793,7 +793,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcStartGroupId, sizeof(pExchNode->srcStartGroupId));
|
||||
if (NULL == group) {
|
||||
qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
nodeNum += group->nodeNum;
|
||||
|
@ -1585,7 +1585,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
}
|
||||
default:
|
||||
qError("not supported physical node type %d", pNode->type);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1594,7 +1594,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
|||
int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) {
|
||||
if (NULL == pResNode) {
|
||||
qError("explain res node is NULL");
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
|
@ -1614,7 +1614,7 @@ int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level, b
|
|||
SExplainGroup *group = taosHashGet(ctx->groupHash, &groupId, sizeof(groupId));
|
||||
if (NULL == group) {
|
||||
qError("group %d not in groupHash", groupId);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
group->singleChannel = singleChannel;
|
||||
|
@ -1636,7 +1636,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
|||
int32_t rowNum = taosArrayGetSize(pCtx->rows);
|
||||
if (rowNum <= 0) {
|
||||
qError("empty explain res rows");
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
SSDataBlock *pBlock = createDataBlock();
|
||||
|
@ -1659,11 +1659,11 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) {
|
|||
if (NULL == rsp) {
|
||||
qError("malloc SRetrieveTableRsp failed, size:%d", rspSize);
|
||||
blockDataDestroy(pBlock);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
rsp->completed = 1;
|
||||
rsp->numOfRows = htonl(rowNum);
|
||||
rsp->numOfRows = htobe64((int64_t)rowNum);
|
||||
|
||||
int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock));
|
||||
ASSERT(len == rspSize - sizeof(SRetrieveTableRsp));
|
||||
|
@ -1698,7 +1698,7 @@ int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) {
|
|||
taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == groupHash) {
|
||||
qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
QRY_ERR_JRET(
|
||||
|
@ -1732,7 +1732,7 @@ int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) {
|
|||
|
||||
if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) {
|
||||
qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n);
|
||||
QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1800,7 +1800,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
|
|||
if (NULL == group) {
|
||||
qError("group %d not in groupHash", groupId);
|
||||
tFreeSExplainRsp(pRspMsg);
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
taosWLockLatch(&group->lock);
|
||||
|
@ -1811,7 +1811,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
|
|||
tFreeSExplainRsp(pRspMsg);
|
||||
taosWUnLockLatch(&group->lock);
|
||||
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
group->physiPlanExecNum = pRspMsg->numOfPlans;
|
||||
|
@ -1821,7 +1821,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
|
|||
tFreeSExplainRsp(pRspMsg);
|
||||
taosWUnLockLatch(&group->lock);
|
||||
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
if (group->physiPlanExecNum != pRspMsg->numOfPlans) {
|
||||
|
@ -1830,7 +1830,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t
|
|||
tFreeSExplainRsp(pRspMsg);
|
||||
taosWUnLockLatch(&group->lock);
|
||||
|
||||
QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
QRY_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
taosArrayPush(group->nodeExecInfo, pRspMsg);
|
||||
|
|
|
@ -46,7 +46,6 @@ extern "C" {
|
|||
|
||||
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
|
||||
|
||||
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u)
|
||||
#define IS_VALID_SESSION_WIN(winInfo) ((winInfo).sessionWin.win.skey > 0)
|
||||
#define SET_SESSION_WIN_INVALID(winInfo) ((winInfo).sessionWin.win.skey = INT64_MIN)
|
||||
#define IS_INVALID_SESSION_WIN_KEY(winKey) ((winKey).win.skey <= 0)
|
||||
|
@ -109,6 +108,7 @@ typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr);
|
|||
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr);
|
||||
typedef void (*__optr_close_fn_t)(void* param);
|
||||
typedef int32_t (*__optr_explain_fn_t)(struct SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len);
|
||||
typedef int32_t (*__optr_reqBuf_fn_t)(struct SOperatorInfo* pOptr);
|
||||
|
||||
typedef struct STaskIdInfo {
|
||||
uint64_t queryId; // this is also a request id
|
||||
|
@ -170,8 +170,9 @@ struct SExecTaskInfo {
|
|||
STaskCostInfo cost;
|
||||
int64_t owner; // if it is in execution
|
||||
int32_t code;
|
||||
int32_t qbufQuota; // total available buffer (in KB) during execution query
|
||||
|
||||
int64_t version; // used for stream to record wal version
|
||||
int64_t version; // used for stream to record wal version, why not move to sschemainfo
|
||||
SStreamTaskInfo streamInfo;
|
||||
SSchemaInfo schemaInfo;
|
||||
STableListInfo* pTableInfoList; // this is a table list
|
||||
|
@ -198,6 +199,7 @@ typedef struct SOperatorFpSet {
|
|||
__optr_fn_t getNextFn;
|
||||
__optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP
|
||||
__optr_close_fn_t closeFn;
|
||||
__optr_reqBuf_fn_t reqBufFn; // total used buffer for blocking operator
|
||||
__optr_encode_fn_t encodeResultRow;
|
||||
__optr_decode_fn_t decodeResultRow;
|
||||
__optr_explain_fn_t getExplainFn;
|
||||
|
@ -486,28 +488,20 @@ typedef struct STableCountScanSupp {
|
|||
int16_t dbNameSlotId;
|
||||
int16_t stbNameSlotId;
|
||||
int16_t tbCountSlotId;
|
||||
|
||||
bool groupByDbName;
|
||||
bool groupByStbName;
|
||||
char dbName[TSDB_DB_NAME_LEN];
|
||||
char stbName[TSDB_TABLE_NAME_LEN];
|
||||
|
||||
bool groupByDbName;
|
||||
bool groupByStbName;
|
||||
char dbNameFilter[TSDB_DB_NAME_LEN];
|
||||
char stbNameFilter[TSDB_TABLE_NAME_LEN];
|
||||
} STableCountScanSupp;
|
||||
|
||||
typedef struct STableCountScanOperatorInfo {
|
||||
SReadHandle readHandle;
|
||||
SSDataBlock* pRes;
|
||||
|
||||
SName tableName;
|
||||
|
||||
SNodeList* groupTags;
|
||||
SNodeList* scanCols;
|
||||
SNodeList* pseudoCols;
|
||||
|
||||
STableCountScanSupp supp;
|
||||
|
||||
int32_t currGrpIdx;
|
||||
SArray* stbUidList; // when group by db_name and stable_name
|
||||
SArray* stbUidList; // when group by db_name and/or stable_name
|
||||
} STableCountScanOperatorInfo;
|
||||
|
||||
typedef struct SOptrBasicInfo {
|
||||
|
@ -677,13 +671,14 @@ typedef struct SStreamFillOperatorInfo {
|
|||
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||
|
||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
||||
__optr_close_fn_t closeFn, __optr_explain_fn_t explain);
|
||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
|
||||
__optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, __optr_explain_fn_t explain);
|
||||
int32_t optrDummyOpenFn(SOperatorInfo* pOperator);
|
||||
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
|
||||
void setOperatorCompleted(SOperatorInfo* pOperator);
|
||||
void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status,
|
||||
void* pInfo, SExecTaskInfo* pTaskInfo);
|
||||
void destroyOperatorInfo(SOperatorInfo* pOperator);
|
||||
int32_t optrDefaultBufFn(SOperatorInfo* pOperator);
|
||||
|
||||
void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock);
|
||||
void cleanupBasicInfo(SOptrBasicInfo* pInfo);
|
||||
|
@ -712,7 +707,7 @@ void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pC
|
|||
int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput);
|
||||
|
||||
int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart);
|
||||
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
|
||||
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int32_t dataLen, int64_t startTs,
|
||||
SOperatorInfo* pOperator);
|
||||
|
||||
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
|
||||
|
@ -746,6 +741,8 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
|||
|
||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* handle, STableCountScanPhysiNode* pNode, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pNode, SExecTaskInfo* pTaskInfo);
|
||||
|
||||
SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo);
|
||||
|
@ -818,8 +815,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
|
||||
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList);
|
||||
|
||||
int32_t getMaximumIdleDurationSec();
|
||||
|
||||
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
|
||||
int32_t order);
|
||||
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
|
||||
|
|
|
@ -117,7 +117,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
|||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, destroyCacheScanOperator, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doScanCache, NULL, destroyCacheScanOperator, optrDefaultBufFn, NULL);
|
||||
|
||||
pOperator->cost.openCost = 0;
|
||||
return pOperator;
|
||||
|
|
|
@ -135,12 +135,12 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput,
|
|||
SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle;
|
||||
SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM);
|
||||
if (NULL == pBuf) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!allocBuf(pDeleter, pInput, pBuf)) {
|
||||
taosFreeQitem(pBuf);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
toDataCacheEntry(pDeleter, pInput, pBuf);
|
||||
|
|
|
@ -128,12 +128,12 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput,
|
|||
SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle;
|
||||
SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM);
|
||||
if (NULL == pBuf) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!allocBuf(pDispatcher, pInput, pBuf)) {
|
||||
taosFreeQitem(pBuf);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
toDataCacheEntry(pDispatcher, pInput, pBuf);
|
||||
|
@ -237,8 +237,8 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
|
|||
int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle) {
|
||||
SDataDispatchHandle* dispatcher = taosMemoryCalloc(1, sizeof(SDataDispatchHandle));
|
||||
if (NULL == dispatcher) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
dispatcher->sink.fPut = putDataBlock;
|
||||
dispatcher->sink.fEndPut = endPut;
|
||||
|
@ -254,8 +254,8 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
|
|||
taosThreadMutexInit(&dispatcher->mutex, NULL);
|
||||
if (NULL == dispatcher->pDataBlocks) {
|
||||
taosMemoryFree(dispatcher);
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*pHandle = dispatcher;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -101,7 +101,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
|
|||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == pMsgSendInfo) {
|
||||
taosMemoryFreeClear(pMsg);
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
|
@ -304,8 +304,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
|
|||
void* pParam) {
|
||||
SDataInserterHandle* inserter = taosMemoryCalloc(1, sizeof(SDataInserterHandle));
|
||||
if (NULL == inserter) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SQueryInserterNode* pInserterNode = (SQueryInserterNode*)pDataSink;
|
||||
|
@ -342,8 +342,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat
|
|||
if (NULL == inserter->pDataBlocks) {
|
||||
destroyDataSinker((SDataSinkHandle*)inserter);
|
||||
taosMemoryFree(inserter);
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT),
|
||||
|
|
|
@ -115,14 +115,14 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
|
|||
if (pRsp->completed == 1) {
|
||||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
||||
" execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||
" execId:%d index:%d completed, blocks:%d, numOfRows:%" PRId64 ", rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64
|
||||
", total:%.2f Kb, try next %d/%" PRIzu,
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRsp->numOfBlocks,
|
||||
pRsp->numOfRows, pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0, i + 1,
|
||||
totalSources);
|
||||
} else {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64
|
||||
" execId:%d blocks:%d, numOfRows:%d, totalRows:%" PRIu64 ", total:%.2f Kb",
|
||||
" execId:%d blocks:%d, numOfRows:%" PRId64 ", totalRows:%" PRIu64 ", total:%.2f Kb",
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRsp->numOfBlocks,
|
||||
pRsp->numOfRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) {
|
|||
}
|
||||
}
|
||||
|
||||
static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||
static SSDataBlock* loadRemoteData(SOperatorInfo* pOperator) {
|
||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
|
@ -307,7 +307,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
|||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, destroyExchangeOperatorInfo, NULL);
|
||||
createOperatorFpSet(prepareLoadRemoteData, loadRemoteData, NULL, destroyExchangeOperatorInfo, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
|
@ -367,14 +367,14 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
pSourceDataInfo->pRsp = pMsg->pData;
|
||||
|
||||
SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp;
|
||||
pRsp->numOfRows = htonl(pRsp->numOfRows);
|
||||
pRsp->numOfRows = htobe64(pRsp->numOfRows);
|
||||
pRsp->compLen = htonl(pRsp->compLen);
|
||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||
pRsp->useconds = htobe64(pRsp->useconds);
|
||||
pRsp->numOfBlocks = htonl(pRsp->numOfBlocks);
|
||||
|
||||
ASSERT(pRsp != NULL);
|
||||
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
||||
qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%" PRId64 ", %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks,
|
||||
pRsp->numOfRows, pExchangeInfo);
|
||||
} else {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
@ -424,20 +424,20 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
|
|||
|
||||
int32_t msgSize = tSerializeSResFetchReq(NULL, 0, &req);
|
||||
if (msgSize < 0) {
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pWrapper);
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
void* msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pWrapper);
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) {
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pWrapper);
|
||||
taosMemoryFree(msg);
|
||||
return pTaskInfo->code;
|
||||
|
@ -453,7 +453,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
|
|||
taosMemoryFreeClear(msg);
|
||||
taosMemoryFree(pWrapper);
|
||||
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return pTaskInfo->code;
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
|
||||
void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int32_t dataLen, int64_t startTs,
|
||||
SOperatorInfo* pOperator) {
|
||||
pInfo->totalRows += numOfRows;
|
||||
pInfo->totalSize += dataLen;
|
||||
|
@ -570,13 +570,10 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
|||
|
||||
pOperator->status = OP_RES_TO_RETURN;
|
||||
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||
|
||||
tsem_wait(&pExchangeInfo->ready);
|
||||
if (isTaskKilled(pTaskInfo)) {
|
||||
longjmp(pTaskInfo->env, pTaskInfo->code);
|
||||
}
|
||||
|
||||
tsem_post(&pExchangeInfo->ready);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -655,7 +652,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|||
|
||||
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
|
||||
if (pRsp->completed == 1) {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%" PRId64 ", rowsOfSource:%" PRIu64
|
||||
", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu,
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
||||
pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1,
|
||||
|
@ -664,7 +661,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) {
|
|||
pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED;
|
||||
pExchangeInfo->current += 1;
|
||||
} else {
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64
|
||||
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%" PRId64 ", totalRows:%" PRIu64
|
||||
", totalBytes:%" PRIu64,
|
||||
GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows,
|
||||
pLoadInfo->totalRows, pLoadInfo->totalSize);
|
||||
|
|
|
@ -129,6 +129,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
|
|||
void* pData = NULL;
|
||||
pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES);
|
||||
|
||||
// todo avoid repeated malloc memory
|
||||
size_t keyLen = 0;
|
||||
int32_t iter = 0;
|
||||
while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) {
|
||||
|
@ -438,13 +439,12 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
removeInvalidTable(uidList, tags);
|
||||
|
||||
int32_t rows = taosArrayGetSize(uidList);
|
||||
if (rows == 0) {
|
||||
goto end;
|
||||
}
|
||||
// int64_t stt1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt);
|
||||
|
||||
code = blockDataEnsureCapacity(pResBlock, rows);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -452,7 +452,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
|
|||
goto end;
|
||||
}
|
||||
|
||||
// int64_t st = taosGetTimestampUs();
|
||||
for (int32_t i = 0; i < rows; i++) {
|
||||
int64_t* uid = taosArrayGet(uidList, i);
|
||||
for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) {
|
||||
|
@ -467,7 +466,9 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray*
|
|||
#endif
|
||||
} else {
|
||||
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
|
||||
ASSERT(tag);
|
||||
if (tag == NULL) {
|
||||
continue;
|
||||
}
|
||||
STagVal tagVal = {0};
|
||||
tagVal.cid = pColInfo->info.colId;
|
||||
const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal);
|
||||
|
@ -923,14 +924,14 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
|
|||
return -1;
|
||||
}
|
||||
|
||||
SArray* pTbList = getTableNameList(pList);
|
||||
int32_t numOfTables = taosArrayGetSize(pTbList);
|
||||
SHashObj *uHash = NULL;
|
||||
SArray* pTbList = getTableNameList(pList);
|
||||
int32_t numOfTables = taosArrayGetSize(pTbList);
|
||||
SHashObj* uHash = NULL;
|
||||
size_t listlen = taosArrayGetSize(list); // len > 0 means there already have uids
|
||||
if (listlen > 0) {
|
||||
uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
for (int i = 0; i < listlen; i++) {
|
||||
int64_t *uid = taosArrayGet(list, i);
|
||||
int64_t* uid = taosArrayGet(list, i);
|
||||
taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i));
|
||||
}
|
||||
}
|
||||
|
@ -1241,6 +1242,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
|||
}
|
||||
}
|
||||
|
||||
// set the output flag for each column in SColMatchInfo, according to the
|
||||
*numOfOutputCols = 0;
|
||||
int32_t num = LIST_LENGTH(pOutputNodeList->pSlots);
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
|
@ -1456,7 +1458,7 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu
|
|||
SqlFunctionCtx* p = NULL;
|
||||
SqlFunctionCtx** pValCtx = taosMemoryCalloc(numOfOutput, POINTER_BYTES);
|
||||
if (pValCtx == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||
|
@ -1537,8 +1539,6 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
pCtx->start.key = INT64_MIN;
|
||||
pCtx->end.key = INT64_MIN;
|
||||
pCtx->numOfParams = pExpr->base.numOfParams;
|
||||
pCtx->isStream = false;
|
||||
|
||||
pCtx->param = pFunct->pParam;
|
||||
pCtx->saveHandle.currentPage = -1;
|
||||
}
|
||||
|
@ -1602,20 +1602,22 @@ SColumn extractColumnFromColumnNode(SColumnNode* pColNode) {
|
|||
int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) {
|
||||
pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols);
|
||||
|
||||
pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo));
|
||||
if (pCond->colList == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t)*pCond->numOfCols);
|
||||
if (pCond->colList == NULL || pCond->pSlotList == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFreeClear(pCond->colList);
|
||||
taosMemoryFreeClear(pCond->pSlotList);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
// pCond->twindow = pTableScanNode->scanRange;
|
||||
// TODO: get it from stable scan node
|
||||
pCond->twindows = pTableScanNode->scanRange;
|
||||
pCond->suid = pTableScanNode->scan.suid;
|
||||
pCond->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pCond->startVersion = -1;
|
||||
pCond->endVersion = -1;
|
||||
// pCond->type = pTableScanNode->scanFlag;
|
||||
|
||||
int32_t j = 0;
|
||||
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||
|
@ -1628,6 +1630,8 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
|
|||
pCond->colList[j].type = pColNode->node.resType.type;
|
||||
pCond->colList[j].bytes = pColNode->node.resType.bytes;
|
||||
pCond->colList[j].colId = pColNode->colId;
|
||||
|
||||
pCond->pSlotList[j] = pNode->slotId;
|
||||
j += 1;
|
||||
}
|
||||
|
||||
|
@ -1635,7 +1639,10 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) { taosMemoryFreeClear(pCond->colList); }
|
||||
void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) {
|
||||
taosMemoryFreeClear(pCond->colList);
|
||||
taosMemoryFreeClear(pCond->pSlotList);
|
||||
}
|
||||
|
||||
int32_t convertFillType(int32_t mode) {
|
||||
int32_t type = TSDB_FILL_NONE;
|
||||
|
@ -1965,7 +1972,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle*
|
|||
|
||||
int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
|
||||
STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
|
||||
struct SExecTaskInfo* pTaskInfo) {
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
const char* idStr = GET_TASKID(pTaskInfo);
|
||||
|
||||
|
@ -2012,4 +2019,4 @@ void printDataBlock(SSDataBlock* pBlock, const char* flag) {
|
|||
char* pBuf = NULL;
|
||||
qDebug("%s", dumpBlockData(pBlock, flag, &pBuf));
|
||||
taosMemoryFree(pBuf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ static int32_t doSetSMABlock(SOperatorInfo* pOperator, void* input, size_t numOf
|
|||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
if (pOperator->numOfDownstream == 0) {
|
||||
qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pOperator->numOfDownstream > 1) { // not handle this in join query
|
||||
qError("join not supported for stream block scan, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
return doSetSMABlock(pOperator->pDownstream[0], input, numOfBlocks, type, id);
|
||||
|
@ -76,12 +76,12 @@ static int32_t doSetStreamOpOpen(SOperatorInfo* pOperator, char* id) {
|
|||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
if (pOperator->numOfDownstream == 0) {
|
||||
qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pOperator->numOfDownstream > 1) { // not handle this in join query
|
||||
qError("join not supported for stream block scan, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
return doSetStreamOpOpen(pOperator->pDownstream[0], id);
|
||||
|
@ -95,12 +95,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
if (pOperator->numOfDownstream == 0) {
|
||||
qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pOperator->numOfDownstream > 1) { // not handle this in join query
|
||||
qError("join not supported for stream block scan, %s" PRIx64, id);
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, id);
|
||||
|
@ -139,7 +139,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
|
||||
int32_t qSetStreamOpOpen(qTaskInfo_t tinfo) {
|
||||
if (tinfo == NULL) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
|
@ -156,7 +156,7 @@ int32_t qSetStreamOpOpen(qTaskInfo_t tinfo) {
|
|||
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||
if (tinfo == NULL) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pBlocks == NULL || numOfBlocks == 0) {
|
||||
|
@ -177,7 +177,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
|
||||
int32_t qSetSMAInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||
if (tinfo == NULL) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pBlocks == NULL || numOfBlocks == 0) {
|
||||
|
@ -207,7 +207,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n
|
|||
}
|
||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||
|
||||
pTaskInfo->cost.created = taosGetTimestampMs();
|
||||
pTaskInfo->cost.created = taosGetTimestampUs();
|
||||
pTaskInfo->execModel = OPTR_EXEC_MODEL_QUEUE;
|
||||
pTaskInfo->pRoot = createRawScanOperatorInfo(readers, pTaskInfo);
|
||||
if (NULL == pTaskInfo->pRoot) {
|
||||
|
@ -503,7 +503,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
}
|
||||
|
||||
if (pTaskInfo->cost.start == 0) {
|
||||
pTaskInfo->cost.start = taosGetTimestampMs();
|
||||
pTaskInfo->cost.start = taosGetTimestampUs();
|
||||
}
|
||||
|
||||
if (isTaskKilled(pTaskInfo)) {
|
||||
|
@ -597,7 +597,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) {
|
|||
}
|
||||
|
||||
if (pTaskInfo->cost.start == 0) {
|
||||
pTaskInfo->cost.start = taosGetTimestampMs();
|
||||
pTaskInfo->cost.start = taosGetTimestampUs();
|
||||
}
|
||||
|
||||
if (isTaskKilled(pTaskInfo)) {
|
||||
|
@ -706,15 +706,20 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo, int32_t rspCode) {
|
|||
|
||||
static void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo) {
|
||||
STaskCostInfo* pSummary = &pTaskInfo->cost;
|
||||
int64_t idleTime = pSummary->start - pSummary->created;
|
||||
|
||||
SFileBlockLoadRecorder* pRecorder = pSummary->pRecoder;
|
||||
if (pSummary->pRecoder != NULL) {
|
||||
qDebug(
|
||||
"%s :cost summary: elapsed time:%.2f ms, extract tableList:%.2f ms, createGroupIdMap:%.2f ms, total blocks:%d, "
|
||||
"%s :cost summary: idle:%.2f ms, elapsed time:%.2f ms, extract tableList:%.2f ms, "
|
||||
"createGroupIdMap:%.2f ms, total blocks:%d, "
|
||||
"load block SMA:%d, load data block:%d, total rows:%" PRId64 ", check rows:%" PRId64,
|
||||
GET_TASKID(pTaskInfo), pSummary->elapsedTime / 1000.0, pSummary->extractListTime, pSummary->groupIdMapTime,
|
||||
pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks, pRecorder->totalRows,
|
||||
pRecorder->totalCheckedRows);
|
||||
GET_TASKID(pTaskInfo), idleTime / 1000.0, pSummary->elapsedTime / 1000.0, pSummary->extractListTime,
|
||||
pSummary->groupIdMapTime, pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks,
|
||||
pRecorder->totalRows, pRecorder->totalCheckedRows);
|
||||
} else {
|
||||
qDebug("%s :cost summary: idle in queue:%.2f ms, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), idleTime / 1000.0,
|
||||
pSummary->elapsedTime / 1000.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,21 +976,27 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s
|
|||
pCond->order = TSDB_ORDER_ASC;
|
||||
pCond->numOfCols = pMtInfo->schema->nCols;
|
||||
pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo));
|
||||
if (pCond->colList == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t) * pCond->numOfCols);
|
||||
if (pCond->colList == NULL || pCond->pSlotList == NULL) {
|
||||
taosMemoryFreeClear(pCond->colList);
|
||||
taosMemoryFreeClear(pCond->pSlotList);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
|
||||
pCond->twindows = TSWINDOW_INITIALIZER;
|
||||
pCond->suid = pMtInfo->suid;
|
||||
pCond->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pCond->startVersion = -1;
|
||||
pCond->endVersion = sContext->snapVersion;
|
||||
|
||||
for (int32_t i = 0; i < pCond->numOfCols; ++i) {
|
||||
pCond->colList[i].type = pMtInfo->schema->pSchema[i].type;
|
||||
pCond->colList[i].bytes = pMtInfo->schema->pSchema[i].bytes;
|
||||
pCond->colList[i].colId = pMtInfo->schema->pSchema[i].colId;
|
||||
SColumnInfo* pColInfo = &pCond->colList[i];
|
||||
pColInfo->type = pMtInfo->schema->pSchema[i].type;
|
||||
pColInfo->bytes = pMtInfo->schema->pSchema[i].bytes;
|
||||
pColInfo->colId = pMtInfo->schema->pSchema[i].colId;
|
||||
|
||||
pCond->pSlotList[i] = i;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1078,7 +1089,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
int32_t num = tableListGetSize(pTaskInfo->pTableInfoList);
|
||||
|
||||
if (tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &pTableScanInfo->base.cond, pList, num,
|
||||
&pTableScanInfo->base.dataReader, NULL) < 0 ||
|
||||
pTableScanInfo->pResBlock, &pTableScanInfo->base.dataReader, NULL) < 0 ||
|
||||
pTableScanInfo->base.dataReader == NULL) {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -1130,7 +1141,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
|||
int32_t size = tableListGetSize(pTaskInfo->pTableInfoList);
|
||||
ASSERT(size == 1);
|
||||
|
||||
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, &pInfo->dataReader, NULL);
|
||||
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL);
|
||||
|
||||
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
||||
strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName);
|
||||
|
|
|
@ -85,8 +85,6 @@ typedef struct SAggOperatorInfo {
|
|||
SExprSupp scalarExprSup;
|
||||
} SAggOperatorInfo;
|
||||
|
||||
int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; }
|
||||
|
||||
static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock);
|
||||
|
||||
static void releaseQueryBuf(size_t numOfTables);
|
||||
|
@ -106,7 +104,7 @@ void setOperatorCompleted(SOperatorInfo* pOperator) {
|
|||
pOperator->status = OP_EXEC_DONE;
|
||||
ASSERT(pOperator->pTaskInfo != NULL);
|
||||
|
||||
pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start * 1000) / 1000.0;
|
||||
pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start) / 1000.0;
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
}
|
||||
|
||||
|
@ -120,19 +118,21 @@ void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, b
|
|||
pOperator->pTaskInfo = pTaskInfo;
|
||||
}
|
||||
|
||||
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) {
|
||||
int32_t optrDummyOpenFn(SOperatorInfo* pOperator) {
|
||||
OPTR_SET_OPENED(pOperator);
|
||||
pOperator->cost.openCost = 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup,
|
||||
__optr_close_fn_t closeFn, __optr_explain_fn_t explain) {
|
||||
__optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn,
|
||||
__optr_explain_fn_t explain) {
|
||||
SOperatorFpSet fpSet = {
|
||||
._openFn = openFn,
|
||||
.getNextFn = nextFn,
|
||||
.cleanupFn = cleanup,
|
||||
.closeFn = closeFn,
|
||||
.reqBufFn = reqBufFn,
|
||||
.getExplainFn = explain,
|
||||
};
|
||||
|
||||
|
@ -675,7 +675,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId,
|
||||
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
|
||||
pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
} else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery)) { // stable aggregate, not interval aggregate or normal column aggregate
|
||||
|
@ -726,7 +726,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
|
|||
if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId,
|
||||
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
|
||||
pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -939,10 +939,10 @@ static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, u
|
|||
}
|
||||
|
||||
static void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs,
|
||||
const int32_t* rowCellOffset) {
|
||||
const int32_t* rowEntryOffset) {
|
||||
bool returnNotNull = false;
|
||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||
struct SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowCellOffset);
|
||||
SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||
if (!isRowEntryInitialized(pResInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1145,45 +1145,6 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
|
|||
}
|
||||
}
|
||||
|
||||
// void skipBlocks(STaskRuntimeEnv *pRuntimeEnv) {
|
||||
// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
//
|
||||
// if (pQueryAttr->limit.offset <= 0 || pQueryAttr->numOfFilterCols > 0) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// pQueryAttr->pos = 0;
|
||||
// int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order);
|
||||
//
|
||||
// STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current;
|
||||
// TsdbQueryHandleT pTsdbReadHandle = pRuntimeEnv->pTsdbReadHandle;
|
||||
//
|
||||
// SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER;
|
||||
// while (tsdbNextDataBlock(pTsdbReadHandle)) {
|
||||
// if (isTaskKilled(pRuntimeEnv->qinfo)) {
|
||||
// T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||
// }
|
||||
//
|
||||
// tsdbRetrieveDataBlockInfo(pTsdbReadHandle, &blockInfo);
|
||||
//
|
||||
// if (pQueryAttr->limit.offset > blockInfo.rows) {
|
||||
// pQueryAttr->limit.offset -= blockInfo.rows;
|
||||
// pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQueryAttr)) ? blockInfo.window.ekey : blockInfo.window.skey;
|
||||
// pTableQueryInfo->lastKey += step;
|
||||
//
|
||||
// //qDebug("QInfo:0x%"PRIx64" skip rows:%d, offset:%" PRId64, GET_TASKID(pRuntimeEnv), blockInfo.rows,
|
||||
// pQuery->limit.offset);
|
||||
// } else { // find the appropriated start position in current block
|
||||
// updateOffsetVal(pRuntimeEnv, &blockInfo);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (terrno != TSDB_CODE_SUCCESS) {
|
||||
// T_LONG_JMP(pRuntimeEnv->env, terrno);
|
||||
// }
|
||||
// }
|
||||
|
||||
// static TSKEY doSkipIntervalProcess(STaskRuntimeEnv* pRuntimeEnv, STimeWindow* win, SDataBlockInfo* pBlockInfo,
|
||||
// STableQueryInfo* pTableQueryInfo) {
|
||||
// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
|
@ -1408,11 +1369,11 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
|
|||
|
||||
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
|
||||
bool hasCountFunc = false;
|
||||
|
||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
||||
if ((strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "count") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "hyperloglog") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_partial") == 0) ||
|
||||
(strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_merge") == 0)) {
|
||||
const char* pName = pCtx[i].pExpr->pExpr->_function.functionName;
|
||||
if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) ||
|
||||
(strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) {
|
||||
hasCountFunc = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1465,7 +1426,6 @@ static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock **ppB
|
|||
*ppBlock = NULL;
|
||||
}
|
||||
|
||||
|
||||
// this is a blocking operator
|
||||
static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
|
||||
if (OPTR_IS_OPENED(pOperator)) {
|
||||
|
@ -1616,6 +1576,15 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) {
|
|||
taosMemoryFreeClear(pOperator);
|
||||
}
|
||||
|
||||
// each operator should be set their own function to return total cost buffer
|
||||
int32_t optrDefaultBufFn(SOperatorInfo* pOperator) {
|
||||
if (pOperator->blocking) {
|
||||
ASSERT(0);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz) {
|
||||
*defaultPgsz = 4096;
|
||||
while (*defaultPgsz < rowSize * 4) {
|
||||
|
@ -1641,7 +1610,7 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n
|
|||
pAggSup->currentPageId = -1;
|
||||
pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput);
|
||||
pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t));
|
||||
pAggSup->pResultRowHashTable = tSimpleHashInit(10, hashFn);
|
||||
pAggSup->pResultRowHashTable = tSimpleHashInit(100, hashFn);
|
||||
|
||||
if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -1796,7 +1765,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
|
|||
|
||||
setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
||||
STableScanInfo* pTableScanInfo = downstream->info;
|
||||
|
@ -1857,7 +1826,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
|||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||
|
||||
pTaskInfo->schemaInfo.dbname = strdup(dbFName);
|
||||
pTaskInfo->cost.created = taosGetTimestampMs();
|
||||
pTaskInfo->id.queryId = queryId;
|
||||
pTaskInfo->execModel = model;
|
||||
pTaskInfo->pTableInfoList = tableListCreate();
|
||||
|
@ -1873,8 +1841,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
|
|||
|
||||
SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode);
|
||||
|
||||
SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* handle, STableCountScanPhysiNode* pNode,
|
||||
SExecTaskInfo* pTaskInfo);
|
||||
int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pHandle->meta, 0);
|
||||
|
@ -2230,12 +2196,12 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI
|
|||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
if (pOperator->numOfDownstream == 0) {
|
||||
qError("failed to find stream scan operator");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pOperator->numOfDownstream > 1) {
|
||||
qError("join not supported for stream block scan");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo);
|
||||
} else {
|
||||
|
@ -2253,13 +2219,13 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
|
|||
return 0;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
terrno = TSDB_CODE_QRY_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (LIST_LENGTH(pNode->pChildren) != 1) {
|
||||
ASSERT(0);
|
||||
terrno = TSDB_CODE_QRY_APP_ERROR;
|
||||
terrno = TSDB_CODE_APP_ERROR;
|
||||
return -1;
|
||||
}
|
||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pNode->pChildren, 0);
|
||||
|
@ -2287,7 +2253,7 @@ int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHa
|
|||
if (pTableScanInfo->dataReader == NULL) {
|
||||
ASSERT(0);
|
||||
qError("failed to create data reader");
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
// TODO: set uid and ts to data reader
|
||||
return 0;
|
||||
|
@ -2366,6 +2332,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
goto _complete;
|
||||
}
|
||||
|
||||
(*pTaskInfo)->cost.created = taosGetTimestampUs();
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_complete:
|
||||
|
@ -2461,7 +2428,7 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInf
|
|||
code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pExecInfoList);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
// taosMemoryFreeClear(*pRes);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2478,7 +2445,7 @@ int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResul
|
|||
int32_t size = pAggSup->resultRowSize;
|
||||
|
||||
if (streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*pResult = (SResultRow*)value;
|
||||
ASSERT(*pResult);
|
||||
|
|
|
@ -381,7 +381,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
|||
|
||||
setOperatorInfo(pOperator, "FillOperator", QUERY_NODE_PHYSICAL_PLAN_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->exprSupp.numOfExprs = pInfo->numOfExpr;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
@ -1478,7 +1478,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi
|
|||
pInfo->srcRowIndex = 0;
|
||||
setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -310,7 +310,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
||||
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
int32_t rowIndex = j - num;
|
||||
|
@ -327,7 +327,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
|
||||
len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
int32_t rowIndex = pBlock->info.rows - num;
|
||||
|
@ -470,7 +470,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
|
|||
setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, optrDefaultBufFn, NULL);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
@ -850,7 +850,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
|||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
return pOperator;
|
||||
|
@ -1142,7 +1142,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
pOperator->exprSupp.pExprInfo = pExprInfo;
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
|
|
@ -136,7 +136,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
|||
pInfo->inputOrder = TSDB_ORDER_DESC;
|
||||
}
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, destroyMergeJoinOperator, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doMergeJoin, NULL, destroyMergeJoinOperator, optrDefaultBufFn, NULL);
|
||||
code = appendDownstream(pOperator, pDownstream, numOfDownstream);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
|
|
|
@ -118,8 +118,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
|
|||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols);
|
||||
|
||||
setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL,
|
||||
destroyProjectOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL,
|
||||
destroyProjectOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -415,7 +415,7 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
|
|||
pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr);
|
||||
|
||||
setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -223,10 +223,8 @@ static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsA
|
|||
}
|
||||
|
||||
static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) {
|
||||
bool allColumnsHaveAgg = true;
|
||||
SColumnDataAgg** pColAgg = NULL;
|
||||
|
||||
int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pColAgg, &allColumnsHaveAgg);
|
||||
bool allColumnsHaveAgg = true;
|
||||
int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pBlock->pBlockAgg, &allColumnsHaveAgg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
@ -235,6 +233,7 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock,
|
|||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// if (allColumnsHaveAgg == true) {
|
||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||
|
||||
|
@ -255,6 +254,7 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock,
|
|||
|
||||
pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
|
|||
if (pLimit->offset > 0 && pLimitInfo->remainOffset > 0) {
|
||||
if (pLimitInfo->remainOffset >= pBlock->info.rows) {
|
||||
pLimitInfo->remainOffset -= pBlock->info.rows;
|
||||
pBlock->info.rows = 0;
|
||||
blockDataEmpty(pBlock);
|
||||
qDebug("current block ignore due to offset, current:%" PRId64 ", %s", pLimitInfo->remainOffset, id);
|
||||
} else {
|
||||
blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
|
||||
|
@ -384,12 +384,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
pCost->totalCheckedRows += pBlock->info.rows;
|
||||
pCost->loadBlocks += 1;
|
||||
|
||||
SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL);
|
||||
if (pCols == NULL) {
|
||||
SSDataBlock* p = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL);
|
||||
if (p == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true);
|
||||
ASSERT(p == pBlock);
|
||||
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, pBlock->info.rows);
|
||||
|
||||
// restore the previous value
|
||||
|
@ -486,10 +486,11 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int
|
|||
code = metaGetTableEntryByUidCache(&mr, pBlock->info.id.uid);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
|
||||
qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid,
|
||||
tstrerror(terrno), idStr);
|
||||
qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s",
|
||||
pBlock->info.id.uid, tstrerror(terrno), idStr);
|
||||
} else {
|
||||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr);
|
||||
qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno),
|
||||
idStr);
|
||||
}
|
||||
metaReaderClear(&mr);
|
||||
return terrno;
|
||||
|
@ -637,16 +638,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
|||
continue;
|
||||
}
|
||||
|
||||
blockDataCleanup(pBlock);
|
||||
SDataBlockInfo* pBInfo = &pBlock->info;
|
||||
|
||||
int32_t rows = 0;
|
||||
tsdbRetrieveDataBlockInfo(pTableScanInfo->base.dataReader, &rows, &pBInfo->id.uid, &pBInfo->window);
|
||||
|
||||
blockDataEnsureCapacity(pBlock, rows); // todo remove it latter
|
||||
pBInfo->rows = rows;
|
||||
|
||||
ASSERT(pBInfo->id.uid != 0);
|
||||
ASSERT(pBlock->info.id.uid != 0);
|
||||
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid);
|
||||
|
||||
uint32_t status = 0;
|
||||
|
@ -777,7 +769,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
|||
ASSERT(pInfo->base.dataReader == NULL);
|
||||
|
||||
int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num,
|
||||
(STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||
pInfo->pResBlock, (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
@ -878,11 +870,11 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
pInfo->base.scanFlag = MAIN_SCAN;
|
||||
pInfo->base.pdInfo.interval = extractIntervalInfo(pTableScanNode);
|
||||
pInfo->base.readHandle = *readHandle;
|
||||
pInfo->base.dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||
|
||||
pInfo->sample.sampleRatio = pTableScanNode->ratio;
|
||||
pInfo->sample.seed = taosGetTimestampSec();
|
||||
|
||||
pInfo->base.dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pDescNode);
|
||||
blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity);
|
||||
|
@ -907,8 +899,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
|||
}
|
||||
|
||||
taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo,
|
||||
getTableScannerExecInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo,
|
||||
optrDefaultBufFn, getTableScannerExecInfo);
|
||||
|
||||
// for non-blocking operator, the open cost is always 0
|
||||
pOperator->cost.openCost = 0;
|
||||
|
@ -933,7 +925,7 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo*
|
|||
|
||||
setOperatorInfo(pOperator, "TableSeqScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, false, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScanImpl, NULL, NULL, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
}
|
||||
|
||||
|
@ -993,10 +985,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
|||
SExecTaskInfo* pTaskInfo = pTableScanOp->pTaskInfo;
|
||||
|
||||
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||
blockDataCleanup(pBlock);
|
||||
|
||||
STsdbReader* pReader = NULL;
|
||||
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, (STsdbReader**)&pReader,
|
||||
int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, (STsdbReader**)&pReader,
|
||||
GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
|
@ -1004,21 +994,10 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool hasBlock = tsdbNextDataBlock(pReader);
|
||||
if (hasBlock) {
|
||||
SDataBlockInfo* pBInfo = &pBlock->info;
|
||||
|
||||
int32_t rows = 0;
|
||||
tsdbRetrieveDataBlockInfo(pReader, &rows, &pBInfo->id.uid, &pBInfo->window);
|
||||
|
||||
SArray* pCols = tsdbRetrieveDataBlock(pReader, NULL);
|
||||
blockDataEnsureCapacity(pBlock, rows);
|
||||
pBlock->info.rows = rows;
|
||||
|
||||
relocateColumnData(pBlock, pTableScanInfo->base.matchInfo.pList, pCols, true);
|
||||
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, rows);
|
||||
|
||||
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBInfo->id.uid);
|
||||
if (tsdbNextDataBlock(pReader)) {
|
||||
/*SSDataBlock* p = */tsdbRetrieveDataBlock(pReader, NULL);
|
||||
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows);
|
||||
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid);
|
||||
}
|
||||
|
||||
tsdbReaderClose(pReader);
|
||||
|
@ -1435,8 +1414,8 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
|
|||
NULL);
|
||||
if (closedWin && pInfo->partitionSup.needCalc) {
|
||||
gpId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId);
|
||||
appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid, &gpId,
|
||||
NULL);
|
||||
appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid,
|
||||
&gpId, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2027,20 +2006,13 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) {
|
|||
|
||||
qDebug("tmqsnap doRawScan called");
|
||||
if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) {
|
||||
SSDataBlock* pBlock = &pInfo->pRes;
|
||||
|
||||
if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) {
|
||||
if (isTaskKilled(pTaskInfo)) {
|
||||
longjmp(pTaskInfo->env, pTaskInfo->code);
|
||||
}
|
||||
|
||||
int32_t rows = 0;
|
||||
tsdbRetrieveDataBlockInfo(pInfo->dataReader, &rows, &pBlock->info.id.uid, &pBlock->info.window);
|
||||
pBlock->info.rows = rows;
|
||||
|
||||
SArray* pCols = tsdbRetrieveDataBlock(pInfo->dataReader, NULL);
|
||||
pBlock->pDataBlock = pCols;
|
||||
if (pCols == NULL) {
|
||||
SSDataBlock* pBlock = tsdbRetrieveDataBlock(pInfo->dataReader, NULL);
|
||||
if (pBlock == NULL) {
|
||||
longjmp(pTaskInfo->env, terrno);
|
||||
}
|
||||
|
||||
|
@ -2167,7 +2139,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT
|
|||
setOperatorInfo(pOperator, "RawScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, false, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, destroyRawScanOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, destroyRawScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
|
||||
_end:
|
||||
|
@ -2211,7 +2183,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
|
@ -2286,7 +2258,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
if (pHandle->initTableReader) {
|
||||
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||
pTSInfo->base.dataReader = NULL;
|
||||
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, &pTSInfo->base.dataReader, NULL);
|
||||
code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, &pTSInfo->base.dataReader, NULL);
|
||||
if (code != 0) {
|
||||
terrno = code;
|
||||
destroyTableScanOperatorInfo(pTableScanOp);
|
||||
|
@ -2356,7 +2328,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||
|
||||
__optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan;
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
return pOperator;
|
||||
|
||||
|
@ -2461,7 +2433,8 @@ static void destroyTagScanOperatorInfo(void* param) {
|
|||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) {
|
||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
|
@ -2492,7 +2465,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
|||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
return pOperator;
|
||||
|
||||
|
@ -2510,17 +2483,14 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
int32_t readIdx = source->readerIdx;
|
||||
SSDataBlock* pBlock = source->inputBlock;
|
||||
STableMergeScanInfo* pTableScanInfo = pOperator->info;
|
||||
|
||||
SQueryTableDataCond* pQueryCond = taosArrayGet(pTableScanInfo->queryConds, readIdx);
|
||||
blockDataCleanup(pBlock);
|
||||
SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx);
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
||||
void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex);
|
||||
SReadHandle* pHandle = &pInfo->base.readHandle;
|
||||
|
||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo));
|
||||
if (code != 0) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
}
|
||||
|
@ -2532,18 +2502,11 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
|||
}
|
||||
|
||||
// process this data block based on the probabilities
|
||||
bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample);
|
||||
bool processThisBlock = processBlockWithProbability(&pInfo->sample);
|
||||
if (!processThisBlock) {
|
||||
continue;
|
||||
}
|
||||
|
||||
blockDataCleanup(pBlock);
|
||||
|
||||
int32_t rows = 0;
|
||||
tsdbRetrieveDataBlockInfo(reader, &rows, &pBlock->info.id.uid, &pBlock->info.window);
|
||||
blockDataEnsureCapacity(pBlock, rows);
|
||||
pBlock->info.rows = rows;
|
||||
|
||||
if (pQueryCond->order == TSDB_ORDER_ASC) {
|
||||
pQueryCond->twindows.skey = pBlock->info.window.ekey + 1;
|
||||
} else {
|
||||
|
@ -2551,7 +2514,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
|||
}
|
||||
|
||||
uint32_t status = 0;
|
||||
loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status);
|
||||
loadDataBlock(pOperator, &pInfo->base, pBlock, &status);
|
||||
// code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, code);
|
||||
|
@ -2565,7 +2528,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) {
|
|||
pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid);
|
||||
|
||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||
pTableScanInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||
pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||
|
||||
tsdbReaderClose(pInfo->base.dataReader);
|
||||
pInfo->base.dataReader = NULL;
|
||||
|
@ -2645,6 +2608,8 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
|||
param.readerIdx = i;
|
||||
param.pOperator = pOperator;
|
||||
param.inputBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||
blockDataEnsureCapacity(param.inputBlock, pOperator->resultInfo.capacity);
|
||||
|
||||
taosArrayPush(pInfo->sortSourceParams, ¶m);
|
||||
|
||||
SQueryTableDataCond cond;
|
||||
|
@ -2901,8 +2866,8 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
pInfo, pTaskInfo);
|
||||
pOperator->exprSupp.numOfExprs = numOfCols;
|
||||
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, destroyTableMergeScanOperatorInfo,
|
||||
getTableMergeScanExplainExecInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableMergeScan, NULL, destroyTableMergeScanOperatorInfo,
|
||||
optrDefaultBufFn, getTableMergeScanExplainExecInfo);
|
||||
pOperator->cost.openCost = 0;
|
||||
return pOperator;
|
||||
|
||||
|
@ -2917,6 +2882,21 @@ _error:
|
|||
// TableCountScanOperator
|
||||
static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator);
|
||||
static void destoryTableCountScanOperator(void* param);
|
||||
static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, tb_uid_t stbUid);
|
||||
static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName);
|
||||
static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName);
|
||||
static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName);
|
||||
static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes);
|
||||
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum,
|
||||
size_t perfdbTableNum);
|
||||
static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes,
|
||||
size_t infodbTableNum, size_t perfdbTableNum);
|
||||
static const char* GROUP_TAG_DB_NAME = "db_name";
|
||||
static const char* GROUP_TAG_STABLE_NAME = "stable_name";
|
||||
|
||||
|
@ -2978,8 +2958,8 @@ int32_t tblCountScanGetInputs(SNodeList* groupTags, SName* tableName, STableCoun
|
|||
}
|
||||
}
|
||||
} else {
|
||||
strncpy(supp->dbName, tNameGetDbNameP(tableName), TSDB_DB_NAME_LEN);
|
||||
strncpy(supp->stbName, tNameGetTableName(tableName), TSDB_TABLE_NAME_LEN);
|
||||
strncpy(supp->dbNameFilter, tNameGetDbNameP(tableName), TSDB_DB_NAME_LEN);
|
||||
strncpy(supp->stbNameFilter, tNameGetTableName(tableName), TSDB_TABLE_NAME_LEN);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -3035,7 +3015,7 @@ SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* readHandle, STableC
|
|||
setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
|
@ -3061,7 +3041,7 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
|
|||
if (pSupp->stbNameSlotId != -1) {
|
||||
SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId);
|
||||
if (strlen(stbName) != 0) {
|
||||
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
strncpy(varDataVal(varStbName), stbName, strlen(stbName));
|
||||
varDataSetLen(varStbName, strlen(stbName));
|
||||
colDataAppend(colInfoData, 0, varStbName, false);
|
||||
|
@ -3087,33 +3067,43 @@ static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountSc
|
|||
getPerfDbMeta(NULL, &perfdbTableNum);
|
||||
|
||||
if (pSupp->groupByDbName) {
|
||||
if (pInfo->currGrpIdx == 0) {
|
||||
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
||||
pRes->info.id.groupId = groupId;
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||
} else if (pInfo->currGrpIdx == 1) {
|
||||
uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB));
|
||||
pRes->info.id.groupId = groupId;
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||
} else {
|
||||
setOperatorCompleted(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
pInfo->currGrpIdx++;
|
||||
buildSysDbGroupedTableCount(pOperator, pInfo, pSupp, pRes, infodbTableNum, perfdbTableNum);
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
} else {
|
||||
if (strcmp(pSupp->dbName, TSDB_INFORMATION_SCHEMA_DB) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||
} else if (strcmp(pSupp->dbName, TSDB_PERFORMANCE_SCHEMA_DB) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||
} else if (strlen(pSupp->dbName) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, "", "", infodbTableNum + perfdbTableNum, pRes);
|
||||
}
|
||||
setOperatorCompleted(pOperator);
|
||||
buildSysDbFilterTableCount(pOperator, pSupp, pRes, infodbTableNum, perfdbTableNum);
|
||||
return (pRes->info.rows > 0) ? pRes : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes,
|
||||
size_t infodbTableNum, size_t perfdbTableNum) {
|
||||
if (strcmp(pSupp->dbNameFilter, TSDB_INFORMATION_SCHEMA_DB) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||
} else if (strcmp(pSupp->dbNameFilter, TSDB_PERFORMANCE_SCHEMA_DB) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||
} else if (strlen(pSupp->dbNameFilter) == 0) {
|
||||
fillTableCountScanDataBlock(pSupp, "", "", infodbTableNum + perfdbTableNum, pRes);
|
||||
}
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
|
||||
static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum,
|
||||
size_t perfdbTableNum) {
|
||||
if (pInfo->currGrpIdx == 0) {
|
||||
uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB));
|
||||
pRes->info.id.groupId = groupId;
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes);
|
||||
} else if (pInfo->currGrpIdx == 1) {
|
||||
uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB));
|
||||
pRes->info.id.groupId = groupId;
|
||||
fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes);
|
||||
} else {
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
pInfo->currGrpIdx++;
|
||||
}
|
||||
|
||||
static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
STableCountScanOperatorInfo* pInfo = pOperator->info;
|
||||
|
@ -3128,89 +3118,110 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
|
|||
return buildSysDbTableCount(pOperator, pInfo);
|
||||
}
|
||||
|
||||
return buildVnodeDbTableCount(pOperator, pInfo, pSupp, pRes);
|
||||
}
|
||||
|
||||
static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes) {
|
||||
const char* db = NULL;
|
||||
int32_t vgId = 0;
|
||||
char dbName[TSDB_DB_NAME_LEN] = {0};
|
||||
|
||||
{
|
||||
// get dbname
|
||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||
SName sn = {0};
|
||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameGetDbName(&sn, dbName);
|
||||
}
|
||||
// get dbname
|
||||
vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId);
|
||||
SName sn = {0};
|
||||
tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameGetDbName(&sn, dbName);
|
||||
|
||||
if (pSupp->groupByDbName) {
|
||||
if (pSupp->groupByStbName) {
|
||||
if (pInfo->stbUidList == NULL) {
|
||||
pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t));
|
||||
if (vnodeGetStbIdList(pInfo->readHandle.vnode, 0, pInfo->stbUidList) < 0) {
|
||||
qError("vgId:%d, failed to get stb id list error: %s", vgId, terrstr());
|
||||
}
|
||||
buildVnodeGroupedTableCount(pOperator, pInfo, pSupp, pRes, vgId, dbName);
|
||||
} else {
|
||||
buildVnodeFilteredTbCount(pOperator, pInfo, pSupp, pRes, dbName);
|
||||
}
|
||||
return pRes->info.rows > 0 ? pRes : NULL;
|
||||
}
|
||||
|
||||
static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName) {
|
||||
if (pSupp->groupByStbName) {
|
||||
if (pInfo->stbUidList == NULL) {
|
||||
pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t));
|
||||
if (vnodeGetStbIdList(pInfo->readHandle.vnode, 0, pInfo->stbUidList) < 0) {
|
||||
qError("vgId:%d, failed to get stb id list error: %s", vgId, terrstr());
|
||||
}
|
||||
if (pInfo->currGrpIdx < taosArrayGetSize(pInfo->stbUidList)) {
|
||||
tb_uid_t stbUid = *(tb_uid_t*)taosArrayGet(pInfo->stbUidList, pInfo->currGrpIdx);
|
||||
}
|
||||
if (pInfo->currGrpIdx < taosArrayGetSize(pInfo->stbUidList)) {
|
||||
tb_uid_t stbUid = *(tb_uid_t*)taosArrayGet(pInfo->stbUidList, pInfo->currGrpIdx);
|
||||
buildVnodeGroupedStbTableCount(pInfo, pSupp, pRes, dbName, stbUid);
|
||||
|
||||
char stbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
metaGetTableSzNameByUid(pInfo->readHandle.meta, stbUid, stbName);
|
||||
pInfo->currGrpIdx++;
|
||||
} else if (pInfo->currGrpIdx == taosArrayGetSize(pInfo->stbUidList)) {
|
||||
buildVnodeGroupedNtbTableCount(pInfo, pSupp, pRes, dbName);
|
||||
|
||||
char fullStbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, stbName);
|
||||
uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
|
||||
SMetaStbStats stats = {0};
|
||||
metaGetStbStats(pInfo->readHandle.meta, stbUid, &stats);
|
||||
int64_t ctbNum = stats.ctbNum;
|
||||
|
||||
fillTableCountScanDataBlock(pSupp, dbName, stbName, ctbNum, pRes);
|
||||
|
||||
pInfo->currGrpIdx++;
|
||||
} else if (pInfo->currGrpIdx == taosArrayGetSize(pInfo->stbUidList)) {
|
||||
char fullStbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, "");
|
||||
uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
int64_t ntbNum = metaGetNtbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", ntbNum, pRes);
|
||||
|
||||
pInfo->currGrpIdx++;
|
||||
} else {
|
||||
setOperatorCompleted(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
pInfo->currGrpIdx++;
|
||||
} else {
|
||||
uint64_t groupId = calcGroupId(dbName, strlen(dbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", dbTableCount, pRes);
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
} else {
|
||||
if (strlen(pSupp->dbName) != 0) {
|
||||
if (strlen(pSupp->stbName) != 0) {
|
||||
tb_uid_t uid = metaGetTableEntryUidByName(pInfo->readHandle.meta, pSupp->stbName);
|
||||
SMetaStbStats stats = {0};
|
||||
metaGetStbStats(pInfo->readHandle.meta, uid, &stats);
|
||||
int64_t ctbNum = stats.ctbNum;
|
||||
fillTableCountScanDataBlock(pSupp, dbName, pSupp->stbName, ctbNum, pRes);
|
||||
} else {
|
||||
int64_t tbNumVnode = metaGetTbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", tbNumVnode, pRes);
|
||||
}
|
||||
uint64_t groupId = calcGroupId(dbName, strlen(dbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", dbTableCount, pRes);
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
}
|
||||
|
||||
static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo,
|
||||
STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName) {
|
||||
if (strlen(pSupp->dbNameFilter) != 0) {
|
||||
if (strlen(pSupp->stbNameFilter) != 0) {
|
||||
tb_uid_t uid = metaGetTableEntryUidByName(pInfo->readHandle.meta, pSupp->stbNameFilter);
|
||||
SMetaStbStats stats = {0};
|
||||
metaGetStbStats(pInfo->readHandle.meta, uid, &stats);
|
||||
int64_t ctbNum = stats.ctbNum;
|
||||
fillTableCountScanDataBlock(pSupp, dbName, pSupp->stbNameFilter, ctbNum, pRes);
|
||||
} else {
|
||||
int64_t tbNumVnode = metaGetTbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", tbNumVnode, pRes);
|
||||
}
|
||||
setOperatorCompleted(pOperator);
|
||||
} else {
|
||||
int64_t tbNumVnode = metaGetTbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", tbNumVnode, pRes);
|
||||
}
|
||||
return pRes->info.rows > 0 ? pRes : NULL;
|
||||
setOperatorCompleted(pOperator);
|
||||
}
|
||||
|
||||
static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName) {
|
||||
char fullStbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, "");
|
||||
uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
int64_t ntbNum = metaGetNtbNum(pInfo->readHandle.meta);
|
||||
fillTableCountScanDataBlock(pSupp, dbName, "", ntbNum, pRes);
|
||||
}
|
||||
|
||||
static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp,
|
||||
SSDataBlock* pRes, char* dbName, tb_uid_t stbUid) {
|
||||
char stbName[TSDB_TABLE_NAME_LEN] = {0};
|
||||
metaGetTableSzNameByUid(pInfo->readHandle.meta, stbUid, stbName);
|
||||
|
||||
char fullStbName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, stbName);
|
||||
uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName));
|
||||
pRes->info.id.groupId = groupId;
|
||||
|
||||
SMetaStbStats stats = {0};
|
||||
metaGetStbStats(pInfo->readHandle.meta, stbUid, &stats);
|
||||
int64_t ctbNum = stats.ctbNum;
|
||||
|
||||
fillTableCountScanDataBlock(pSupp, dbName, stbName, ctbNum, pRes);
|
||||
}
|
||||
|
||||
static void destoryTableCountScanOperator(void* param) {
|
||||
STableCountScanOperatorInfo* pTableCountScanInfo = param;
|
||||
blockDataDestroy(pTableCountScanInfo->pRes);
|
||||
|
||||
nodesDestroyList(pTableCountScanInfo->groupTags);
|
||||
taosArrayDestroy(pTableCountScanInfo->stbUidList);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
|
|||
// TODO dynamic set the available sort buffer
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(doOpenSortOperator, doSort, NULL, destroySortOperatorInfo, getExplainExecInfo);
|
||||
createOperatorFpSet(doOpenSortOperator, doSort, NULL, destroySortOperatorInfo, optrDefaultBufFn, getExplainExecInfo);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -521,8 +521,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort
|
|||
|
||||
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
|
||||
setOperatorInfo(pOperator, "GroupSortOperator", QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, destroyGroupSortOperatorInfo,
|
||||
getGroupSortExplainExecInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doGroupSort, NULL, destroyGroupSortOperatorInfo,
|
||||
optrDefaultBufFn, getGroupSortExplainExecInfo);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -559,7 +559,7 @@ typedef struct SMultiwayMergeOperatorInfo {
|
|||
STupleHandle* prefetchedTuple;
|
||||
} SMultiwayMergeOperatorInfo;
|
||||
|
||||
int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
|
||||
int32_t openMultiwayMergeOperator(SOperatorInfo* pOperator) {
|
||||
SMultiwayMergeOperatorInfo* pInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
|
||||
|
@ -577,9 +577,15 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
|
|||
tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort);
|
||||
|
||||
for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
|
||||
SOperatorInfo* pDownstream = pOperator->pDownstream[i];
|
||||
if (pDownstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_EXCHANGE) {
|
||||
pDownstream->fpSet._openFn(pDownstream);
|
||||
}
|
||||
|
||||
SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource));
|
||||
ps->param = pOperator->pDownstream[i];
|
||||
ps->param = pDownstream;
|
||||
ps->onlyRef = true;
|
||||
|
||||
tsortAddSource(pInfo->pSortHandle, ps);
|
||||
}
|
||||
|
||||
|
@ -714,7 +720,6 @@ SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
qDebug("start to merge final sorted rows, %s", GET_TASKID(pTaskInfo));
|
||||
|
||||
SSDataBlock* pBlock = getMultiwaySortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pInfo->matchInfo.pList, pOperator);
|
||||
if (pBlock != NULL) {
|
||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||
|
@ -781,7 +786,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
|
|||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0);
|
||||
SSDataBlock* pInputBlock = createDataBlockFromDescNode(pChildNode->pOutputDataBlockDesc);
|
||||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
pInfo->groupSort = pMergePhyNode->groupSort;
|
||||
|
@ -792,8 +797,8 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
|
|||
pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result.
|
||||
|
||||
setOperatorInfo(pOperator, "MultiwayMergeOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL,
|
||||
destroyMultiwayMergeOperatorInfo, getMultiwayMergeExplainExecInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(openMultiwayMergeOperator, doMultiwayMerge, NULL,
|
||||
destroyMultiwayMergeOperatorInfo, optrDefaultBufFn, getMultiwayMergeExplainExecInfo);
|
||||
|
||||
code = appendDownstream(pOperator, downStreams, numStreams);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
|
|
@ -1335,7 +1335,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
|||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == pMsgSendInfo) {
|
||||
qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo));
|
||||
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
|||
setOperatorInfo(pOperator, "SysTableScanOperator", QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, false, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, destroySysScanOperator, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doSysTableScan, NULL, destroySysScanOperator, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
|
@ -1874,78 +1874,80 @@ static void destroyBlockDistScanOperatorInfo(void* param) {
|
|||
}
|
||||
|
||||
static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pCond) {
|
||||
memset(pCond, 0, sizeof(SQueryTableDataCond));
|
||||
memset(pCond, 0, sizeof(SQueryTableDataCond));
|
||||
|
||||
pCond->order = TSDB_ORDER_ASC;
|
||||
pCond->numOfCols = 1;
|
||||
pCond->colList = taosMemoryCalloc(1, sizeof(SColumnInfo));
|
||||
if (pCond->colList == NULL) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
pCond->order = TSDB_ORDER_ASC;
|
||||
pCond->numOfCols = 1;
|
||||
pCond->colList = taosMemoryCalloc(1, sizeof(SColumnInfo));
|
||||
pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t));
|
||||
if (pCond->colList == NULL || pCond->pSlotList == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
pCond->colList->colId = 1;
|
||||
pCond->colList->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
pCond->colList->bytes = sizeof(TSKEY);
|
||||
pCond->colList->colId = 1;
|
||||
pCond->colList->type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
pCond->colList->bytes = sizeof(TSKEY);
|
||||
|
||||
pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
|
||||
pCond->suid = uid;
|
||||
pCond->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pCond->startVersion = -1;
|
||||
pCond->endVersion = -1;
|
||||
pCond->pSlotList[0] = 0;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX};
|
||||
pCond->suid = uid;
|
||||
pCond->type = TIMEWINDOW_RANGE_CONTAINED;
|
||||
pCond->startVersion = -1;
|
||||
pCond->endVersion = -1;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
{
|
||||
SQueryTableDataCond cond = {0};
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pBlockScanNode->node.pOutputDataBlockDesc);
|
||||
blockDataEnsureCapacity(pInfo->pResBlock, 1);
|
||||
|
||||
int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList;
|
||||
size_t num = tableListGetSize(pTableListInfo);
|
||||
void* pList = tableListGetInfo(pTableListInfo, 0);
|
||||
|
||||
code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, &pInfo->pHandle, pTaskInfo->id.str);
|
||||
cleanupQueryTableDataCond(&cond);
|
||||
if (code != 0) {
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
pInfo->readHandle = *readHandle;
|
||||
pInfo->uid = pBlockScanNode->suid;
|
||||
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pBlockScanNode->node.pOutputDataBlockDesc);
|
||||
blockDataEnsureCapacity(pInfo->pResBlock, 1);
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols);
|
||||
int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols);
|
||||
{
|
||||
SQueryTableDataCond cond = {0};
|
||||
int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
goto _error;
|
||||
}
|
||||
|
||||
setOperatorInfo(pOperator, "DataBlockDistScanOperator", QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, false,
|
||||
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, destroyBlockDistScanOperatorInfo, NULL);
|
||||
return pOperator;
|
||||
STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList;
|
||||
size_t num = tableListGetSize(pTableListInfo);
|
||||
void* pList = tableListGetInfo(pTableListInfo, 0);
|
||||
|
||||
_error:
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
return NULL;
|
||||
code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str);
|
||||
cleanupQueryTableDataCond(&cond);
|
||||
if (code != 0) {
|
||||
goto _error;
|
||||
}
|
||||
}
|
||||
|
||||
pInfo->readHandle = *readHandle;
|
||||
pInfo->uid = pBlockScanNode->suid;
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols);
|
||||
int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
setOperatorInfo(pOperator, "DataBlockDistScanOperator", QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, false,
|
||||
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(optrDummyOpenFn, doBlockInfoScan, NULL, destroyBlockDistScanOperatorInfo, optrDefaultBufFn, NULL);
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
taosMemoryFreeClear(pInfo);
|
||||
taosMemoryFreeClear(pOperator);
|
||||
return NULL;
|
||||
}
|
|
@ -45,8 +45,18 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd
|
|||
if (pCol->notFillCol) {
|
||||
bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex);
|
||||
if (!filled) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal;
|
||||
SGroupKeys* pKey = taosArrayGet(p, i);
|
||||
SRowVal* p = NULL;
|
||||
if (FILL_IS_ASC_FILL(pFillInfo)) {
|
||||
if (pFillInfo->prev.key != 0) {
|
||||
p = &pFillInfo->prev; // prev has been set value
|
||||
} else { // otherwise, use the value in the next row
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
} else {
|
||||
p = &pFillInfo->next;
|
||||
}
|
||||
|
||||
SGroupKeys* pKey = taosArrayGet(p->pRowVal, i);
|
||||
doSetVal(pDstColInfo, rowIndex, pKey);
|
||||
}
|
||||
} else {
|
||||
|
@ -246,7 +256,10 @@ static void initBeforeAfterDataBuf(SFillInfo* pFillInfo) {
|
|||
|
||||
static void saveColData(SArray* rowBuf, int32_t columnIndex, const char* src, bool isNull);
|
||||
|
||||
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray* pRow) {
|
||||
static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVal* pRowVal) {
|
||||
SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId);
|
||||
pRowVal->key = ((int64_t*)pTsCol->pData)[rowIndex];
|
||||
|
||||
for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||
int32_t type = pFillInfo->pFillCol[i].pExpr->pExpr->nodeType;
|
||||
if (type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) {
|
||||
|
@ -257,7 +270,7 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray
|
|||
bool isNull = colDataIsNull_s(pSrcCol, rowIndex);
|
||||
char* p = colDataGetData(pSrcCol, rowIndex);
|
||||
|
||||
saveColData(pRow, i, p, isNull);
|
||||
saveColData(pRowVal->pRowVal, i, p, isNull);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -281,7 +294,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
|
||||
// set the next value for interpolation
|
||||
if ((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) {
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next.pRowVal);
|
||||
copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, &pFillInfo->next);
|
||||
}
|
||||
|
||||
if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||
|
@ -303,7 +316,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
|
||||
if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) {
|
||||
int32_t nextRowIndex = pFillInfo->index + 1;
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, pFillInfo->next.pRowVal);
|
||||
copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, &pFillInfo->next);
|
||||
}
|
||||
|
||||
// copy rows to dst buffer
|
||||
|
@ -319,6 +332,9 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
if (!colDataIsNull_s(pSrc, pFillInfo->index)) {
|
||||
colDataAppend(pDst, index, src, false);
|
||||
saveColData(pFillInfo->prev.pRowVal, i, src, false);
|
||||
if (pFillInfo->srcTsSlotId == dstSlotId) {
|
||||
pFillInfo->prev.key = *(int64_t*)src;
|
||||
}
|
||||
} else { // the value is null
|
||||
if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false);
|
||||
|
|
|
@ -544,7 +544,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
|
|||
|
||||
setOperatorInfo(pOperator, "TimeSliceOperator", QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC, false, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, destroyTimeSliceOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTimeslice, NULL, destroyTimeSliceOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
|
|
|
@ -648,7 +648,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
|
|||
int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx,
|
||||
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ASSERT(!isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP));
|
||||
|
@ -927,7 +927,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
|
||||
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TSKEY ekey = ascScan ? win.ekey : win.skey;
|
||||
int32_t forwardRows =
|
||||
|
@ -943,7 +943,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
|
||||
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
// window start key interpolation
|
||||
|
@ -967,7 +967,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
|
|||
int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
|
||||
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ekey = ascScan ? nextWin.ekey : nextWin.skey;
|
||||
|
@ -1049,14 +1049,14 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
|
||||
SIntervalAggOperatorInfo* pInfo = pOperator->info;
|
||||
SExprSupp* pSup = &pOperator->exprSupp;
|
||||
|
||||
int32_t scanFlag = MAIN_SCAN;
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
SOperatorInfo* downstream = pOperator->pDownstream[0];
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
while (1) {
|
||||
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
|
||||
|
@ -1150,7 +1150,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
|||
int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx,
|
||||
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &window, false);
|
||||
|
@ -1175,7 +1175,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
|
|||
int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid,
|
||||
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||
|
@ -1268,15 +1268,11 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
|
|||
}
|
||||
|
||||
SSDataBlock* pBlock = pInfo->binfo.pRes;
|
||||
|
||||
ASSERT(pInfo->execModel == OPTR_EXEC_MODEL_BATCH);
|
||||
|
||||
pTaskInfo->code = pOperator->fpSet._openFn(pOperator);
|
||||
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
blockDataEnsureCapacity(pBlock, pOperator->resultInfo.capacity);
|
||||
while (1) {
|
||||
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
|
||||
doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL);
|
||||
|
@ -1649,23 +1645,34 @@ static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) {
|
|||
static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SIntervalAggOperatorInfo* pInfo) {
|
||||
// the primary timestamp column
|
||||
bool needed = false;
|
||||
pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn));
|
||||
pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
|
||||
{ // ts column
|
||||
SColumn c = {0};
|
||||
c.colId = 1;
|
||||
c.slotId = pInfo->primaryTsIndex;
|
||||
c.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
c.bytes = sizeof(int64_t);
|
||||
taosArrayPush(pInfo->pInterpCols, &c);
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SExprInfo* pExpr = pCtx[i].pExpr;
|
||||
if (fmIsIntervalInterpoFunc(pCtx[i].functionId)) {
|
||||
needed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SGroupKeys key = {0};
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = true; // to denote no value is assigned yet
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
taosArrayPush(pInfo->pPrevValues, &key);
|
||||
if (needed) {
|
||||
pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn));
|
||||
pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
|
||||
{ // ts column
|
||||
SColumn c = {0};
|
||||
c.colId = 1;
|
||||
c.slotId = pInfo->primaryTsIndex;
|
||||
c.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
c.bytes = sizeof(int64_t);
|
||||
taosArrayPush(pInfo->pInterpCols, &c);
|
||||
|
||||
SGroupKeys key;
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = true; // to denote no value is assigned yet
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
taosArrayPush(pInfo->pPrevValues, &key);
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
|
@ -1676,7 +1683,6 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
|
||||
SColumn c = *pParam->pCol;
|
||||
taosArrayPush(pInfo->pInterpCols, &c);
|
||||
needed = true;
|
||||
|
||||
SGroupKeys key = {0};
|
||||
key.bytes = c.bytes;
|
||||
|
@ -1708,7 +1714,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor
|
|||
|
||||
void initStreamFunciton(SqlFunctionCtx* pCtx, int32_t numOfExpr) {
|
||||
for (int32_t i = 0; i < numOfExpr; i++) {
|
||||
pCtx[i].isStream = true;
|
||||
// pCtx[i].isStream = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1727,7 +1733,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
|||
pInfo->primaryTsIndex = ((SColumnNode*)pPhyNode->window.pTspk)->slotId;
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 512);
|
||||
blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
|
||||
|
||||
int32_t num = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num);
|
||||
|
@ -1755,7 +1762,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
|||
pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
|
||||
pInfo->interval = interval;
|
||||
pInfo->execModel = pTaskInfo->execModel;
|
||||
pInfo->twAggSup = as;
|
||||
pInfo->binfo.mergeResultBlock = pPhyNode->window.mergeDataBlock;
|
||||
|
||||
|
@ -1773,11 +1779,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
|||
goto _error;
|
||||
}
|
||||
|
||||
if (isStream) {
|
||||
ASSERT(num > 0);
|
||||
initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
|
||||
}
|
||||
|
||||
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win);
|
||||
pInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, num, pInfo);
|
||||
if (pInfo->timeWindowInterpo) {
|
||||
|
@ -1792,7 +1793,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
|
|||
pInfo, pTaskInfo);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, NULL);
|
||||
createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1854,7 +1855,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx,
|
||||
numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
// pInfo->numOfRows data belong to the current session window
|
||||
|
@ -1873,7 +1874,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
|
|||
int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid,
|
||||
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false);
|
||||
|
@ -2010,7 +2011,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
|
|||
setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo,
|
||||
pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, NULL);
|
||||
createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2083,7 +2084,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
|||
setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, optrDefaultBufFn, NULL);
|
||||
pOperator->pTaskInfo = pTaskInfo;
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -2163,7 +2164,7 @@ static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, S
|
|||
int32_t code = setOutputBuf(pInfo->pState, &parentWin, &pCurResult, pWinRes->groupId, pSup->pCtx, numOfOutput,
|
||||
pSup->rowEntryInfoOffset, &pInfo->aggSup);
|
||||
if (code != TSDB_CODE_SUCCESS || pCurResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
|
@ -2402,7 +2403,7 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
|
|||
int32_t code = setOutputBuf(pInfo->pState, &nextWin, &pResult, groupId, pSup->pCtx, numOfOutput,
|
||||
pSup->rowEntryInfoOffset, &pInfo->aggSup);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (IS_FINAL_OP(pInfo)) {
|
||||
|
@ -2573,7 +2574,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
|
|||
for (int32_t i = 0; i < chIndex + 1 - size; i++) {
|
||||
SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0);
|
||||
if (!pChildOp) {
|
||||
T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
SStreamIntervalOperatorInfo* pTmpInfo = pChildOp->info;
|
||||
pTmpInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE;
|
||||
|
@ -2744,7 +2745,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
pOperator->info = pInfo;
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL);
|
||||
createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
||||
if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) {
|
||||
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
||||
}
|
||||
|
@ -2999,7 +3000,7 @@ static int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindo
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
int32_t code = initSessionOutputBuf(pCurWin, pResult, pSup->pCtx, numOutput, pSup->rowEntryInfoOffset);
|
||||
if (code != TSDB_CODE_SUCCESS || (*pResult) == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
updateTimeWindowInfo(pTimeWindowData, &pCurWin->sessionWin.win, false);
|
||||
applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, pTimeWindowData, startIndex, winRows, rows, numOutput);
|
||||
|
@ -3108,13 +3109,13 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
|||
pAggSup->pResultRows, pStUpdated, pStDeleted);
|
||||
// coverity scan error
|
||||
if (!winInfo.pOutputBuf) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||
pOperator);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
compactSessionWindow(pOperator, &winInfo, pStUpdated, pStDeleted);
|
||||
saveSessionOutputBuf(pAggSup, &winInfo);
|
||||
|
@ -3122,7 +3123,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
|
|||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) {
|
||||
code = saveResult(winInfo, pStUpdated);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) {
|
||||
|
@ -3446,7 +3447,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
|
|||
SOperatorInfo* pChildOp =
|
||||
createStreamFinalSessionAggOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0);
|
||||
if (!pChildOp) {
|
||||
T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pInfo->pChildren, &pChildOp);
|
||||
}
|
||||
|
@ -3556,7 +3557,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
|
|||
setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true,
|
||||
OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
if (downstream) {
|
||||
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
||||
|
@ -3700,8 +3701,8 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream
|
|||
if (pPhyNode->type != QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) {
|
||||
pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR);
|
||||
blockDataEnsureCapacity(pInfo->pUpdateRes, 128);
|
||||
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL,
|
||||
destroyStreamSessionAggOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamSessionSemiAgg, NULL,
|
||||
destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL);
|
||||
}
|
||||
|
||||
setOperatorInfo(pOperator, name, pPhyNode->type, false, OP_NOT_OPENED, pInfo, pTaskInfo);
|
||||
|
@ -3889,14 +3890,14 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
|
|||
code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput,
|
||||
pOperator);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
saveSessionOutputBuf(pAggSup, &curWin.winInfo);
|
||||
|
||||
if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
|
||||
code = saveResult(curWin.winInfo, pSeUpdated);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4061,7 +4062,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, optrDefaultBufFn, NULL);
|
||||
initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -4309,12 +4310,11 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
iaInfo->win = pTaskInfo->window;
|
||||
iaInfo->inputOrder = TSDB_ORDER_ASC;
|
||||
iaInfo->interval = interval;
|
||||
iaInfo->execModel = pTaskInfo->execModel;
|
||||
iaInfo->primaryTsIndex = ((SColumnNode*)pNode->window.pTspk)->slotId;
|
||||
iaInfo->binfo.mergeResultBlock = pNode->window.mergeDataBlock;
|
||||
|
||||
size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
|
||||
initResultSizeInfo(&pOperator->resultInfo, 4096);
|
||||
initResultSizeInfo(&pOperator->resultInfo, 512);
|
||||
|
||||
int32_t num = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num);
|
||||
|
@ -4339,7 +4339,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
false, OP_NOT_OPENED, miaInfo, pTaskInfo);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -4448,7 +4448,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
|
|||
setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
|
||||
numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
TSKEY ekey = ascScan ? win.ekey : win.skey;
|
||||
|
@ -4465,7 +4465,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
|
|||
ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx,
|
||||
numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
// window start key interpolation
|
||||
|
@ -4494,7 +4494,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
|
|||
setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
|
||||
pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo);
|
||||
if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ekey = ascScan ? nextWin.ekey : nextWin.skey;
|
||||
|
@ -4615,7 +4615,6 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
|||
pIntervalInfo->win = pTaskInfo->window;
|
||||
pIntervalInfo->inputOrder = TSDB_ORDER_ASC;
|
||||
pIntervalInfo->interval = interval;
|
||||
pIntervalInfo->execModel = pTaskInfo->execModel;
|
||||
pIntervalInfo->binfo.mergeResultBlock = pIntervalPhyNode->window.mergeDataBlock;
|
||||
pIntervalInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
|
||||
|
||||
|
@ -4645,7 +4644,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
|
|||
setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false,
|
||||
OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, NULL);
|
||||
createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -4861,8 +4860,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
|
||||
setOperatorInfo(pOperator, "StreamIntervalOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, true, OP_NOT_OPENED,
|
||||
pInfo, pTaskInfo);
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL);
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamIntervalAgg, NULL,
|
||||
destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL);
|
||||
|
||||
initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup);
|
||||
code = appendDownstream(pOperator, &downstream, 1);
|
||||
|
|
|
@ -34,14 +34,12 @@ struct SSortHandle {
|
|||
int32_t pageSize;
|
||||
int32_t numOfPages;
|
||||
SDiskbasedBuf* pBuf;
|
||||
|
||||
SArray* pSortInfo;
|
||||
SArray* pOrderedSource;
|
||||
|
||||
int32_t loops;
|
||||
uint64_t sortElapsed;
|
||||
int64_t startTs;
|
||||
uint64_t totalElapsed;
|
||||
SArray* pSortInfo;
|
||||
SArray* pOrderedSource;
|
||||
int32_t loops;
|
||||
uint64_t sortElapsed;
|
||||
int64_t startTs;
|
||||
uint64_t totalElapsed;
|
||||
|
||||
int32_t sourceId;
|
||||
SSDataBlock* pDataBlock;
|
||||
|
@ -99,9 +97,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
|
|||
}
|
||||
|
||||
static int32_t sortComparCleanup(SMsortComparParam* cmpParam) {
|
||||
// NOTICE: pSource may be, if it is SORT_MULTISOURCE_MERGE
|
||||
for (int32_t i = 0; i < cmpParam->numOfSources; ++i) {
|
||||
SSortSource* pSource =
|
||||
cmpParam->pSources[i]; // NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE
|
||||
SSortSource* pSource = cmpParam->pSources[i];
|
||||
blockDataDestroy(pSource->src.pBlock);
|
||||
taosMemoryFreeClear(pSource);
|
||||
}
|
||||
|
@ -158,7 +156,7 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSource
|
|||
SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource));
|
||||
if (pSource == NULL) {
|
||||
taosArrayDestroy(pPageIdList);
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pSource->src.pBlock = pBlock;
|
||||
|
@ -231,15 +229,15 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
|
|||
return doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId, pPageIdList);
|
||||
}
|
||||
|
||||
static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) {
|
||||
static void setCurrentSourceDone(SSortSource* pSource, SSortHandle* pHandle) {
|
||||
pSource->src.rowIndex = -1;
|
||||
++pHandle->numOfCompletedSources;
|
||||
}
|
||||
|
||||
static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int32_t startIndex, int32_t endIndex,
|
||||
static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32_t startIndex, int32_t endIndex,
|
||||
SSortHandle* pHandle) {
|
||||
cmpParam->pSources = taosArrayGet(pSources, startIndex);
|
||||
cmpParam->numOfSources = (endIndex - startIndex + 1);
|
||||
pParam->pSources = taosArrayGet(pSources, startIndex);
|
||||
pParam->numOfSources = (endIndex - startIndex + 1);
|
||||
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -247,7 +245,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
|
|||
if (pHandle->pBuf == NULL) {
|
||||
if (!osTempSpaceAvailable()) {
|
||||
code = TSDB_CODE_NO_AVAIL_DISK;
|
||||
qError("Sort compare init failed since %s", terrstr(code));
|
||||
qError("Sort compare init failed since %s, %s", terrstr(code), pHandle->idStr);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -260,12 +258,12 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
|
|||
}
|
||||
|
||||
if (pHandle->type == SORT_SINGLESOURCE_SORT) {
|
||||
for (int32_t i = 0; i < cmpParam->numOfSources; ++i) {
|
||||
SSortSource* pSource = cmpParam->pSources[i];
|
||||
for (int32_t i = 0; i < pParam->numOfSources; ++i) {
|
||||
SSortSource* pSource = pParam->pSources[i];
|
||||
|
||||
// set current source is done
|
||||
if (taosArrayGetSize(pSource->pageIdList) == 0) {
|
||||
setCurrentSourceIsDone(pSource, pHandle);
|
||||
setCurrentSourceDone(pSource, pHandle);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -280,15 +278,21 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
|
|||
releaseBufPage(pHandle->pBuf, pPage);
|
||||
}
|
||||
} else {
|
||||
for (int32_t i = 0; i < cmpParam->numOfSources; ++i) {
|
||||
SSortSource* pSource = cmpParam->pSources[i];
|
||||
qDebug("start init for the multiway merge sort, %s", pHandle->idStr);
|
||||
int64_t st = taosGetTimestampUs();
|
||||
|
||||
for (int32_t i = 0; i < pParam->numOfSources; ++i) {
|
||||
SSortSource* pSource = pParam->pSources[i];
|
||||
pSource->src.pBlock = pHandle->fetchfp(pSource->param);
|
||||
|
||||
// set current source is done
|
||||
if (pSource->src.pBlock == NULL) {
|
||||
setCurrentSourceIsDone(pSource, pHandle);
|
||||
setCurrentSourceDone(pSource, pHandle);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t et = taosGetTimestampUs();
|
||||
qDebug("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -270,7 +270,7 @@ static void i64VectorSumAVX2(const int64_t* plist, int32_t numOfRows, SAvgRes* p
|
|||
|
||||
#if __AVX2__
|
||||
// find the start position that are aligned to 32bytes address in memory
|
||||
int32_t width = (bitWidth>>3u) / sizeof(int64_t);
|
||||
int32_t width = (bitWidth >> 3u) / sizeof(int64_t);
|
||||
|
||||
int32_t remainder = numOfRows % width;
|
||||
int32_t rounds = numOfRows / width;
|
||||
|
@ -286,20 +286,11 @@ static void i64VectorSumAVX2(const int64_t* plist, int32_t numOfRows, SAvgRes* p
|
|||
}
|
||||
|
||||
// let sum up the final results
|
||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
const int64_t* q = (const int64_t*)∑
|
||||
pRes->sum.isum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
} else {
|
||||
const uint64_t* q = (const uint64_t*)∑
|
||||
pRes->sum.usum += q[0] + q[1] + q[2] + q[3];
|
||||
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.usum += (uint64_t)plist[j + rounds * width];
|
||||
}
|
||||
for (int32_t j = 0; j < remainder; ++j) {
|
||||
pRes->sum.isum += plist[j + rounds * width];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -588,14 +579,14 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
|
|||
const int64_t* plist = (const int64_t*) pCol->pData;
|
||||
|
||||
// 1. If the CPU supports AVX, let's employ AVX instructions to speedup this loop
|
||||
if (simdAvailable) {
|
||||
if (simdAvailable && type == TSDB_DATA_TYPE_BIGINT) {
|
||||
i64VectorSumAVX2(plist, numOfRows, pAvgRes);
|
||||
} else {
|
||||
for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) {
|
||||
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
pAvgRes->sum.isum += plist[i];
|
||||
} else {
|
||||
pAvgRes->sum.isum += (uint64_t)plist[i];
|
||||
pAvgRes->sum.usum += (uint64_t)plist[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,7 +419,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
|
||||
|
||||
if (connectRsp.epSet.numOfEps == 0) {
|
||||
msgInfo->code = TSDB_CODE_MND_APP_ERROR;
|
||||
msgInfo->code = TSDB_CODE_APP_ERROR;
|
||||
goto _return;
|
||||
}
|
||||
|
||||
|
@ -598,9 +598,10 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
|
|||
return 0;
|
||||
}
|
||||
static bool udfdRpcRfp(int32_t code, tmsg_t msgType) {
|
||||
if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK ||
|
||||
code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND|| code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) {
|
||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER ||
|
||||
code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING ||
|
||||
code == TSDB_CODE_APP_IS_STOPPING) {
|
||||
if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -195,7 +195,7 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) {
|
|||
}
|
||||
char *tv = taosMemoryCalloc(1, valLen + 1);
|
||||
if (tv == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
memcpy(tv, pData, valLen);
|
||||
|
@ -259,7 +259,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
|||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||
taosHashCleanup(param->pFilter);
|
||||
indexError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
|||
SIFParam *res = (SIFParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES);
|
||||
if (NULL == res) {
|
||||
indexError("no result for node, type:%d, node:%p", nodeType(node), node);
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
SIF_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
*param = *res;
|
||||
break;
|
||||
|
@ -300,7 +300,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
|||
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||
|
||||
if (NULL == paramList) {
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR &&
|
||||
|
@ -319,7 +319,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
|||
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||
// if (paramList[0].colValType == TSDB_DATA_TYPE_JSON &&
|
||||
// ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) {
|
||||
// return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
// return TSDB_CODE_OUT_OF_MEMORY;
|
||||
//}
|
||||
}
|
||||
*params = paramList;
|
||||
|
@ -335,7 +335,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx *
|
|||
SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam));
|
||||
if (tParams == NULL) {
|
||||
indexError("failed to calloc, nodeList: %p", nodeList);
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SListCell *cell = nodeList->pHead;
|
||||
|
@ -464,7 +464,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
|
|||
SIndexTerm *tm = indexTermCreate(arg->suid, DEFAULT, right->colValType, left->colName, strlen(left->colName),
|
||||
right->condValue, strlen(right->condValue));
|
||||
if (tm == NULL) {
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
||||
|
@ -722,7 +722,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
|||
}
|
||||
|
||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
@ -740,7 +740,7 @@ static EDealRes sifWalkLogic(SNode *pNode, void *context) {
|
|||
}
|
||||
|
||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
return DEAL_RES_CONTINUE;
|
||||
|
@ -756,7 +756,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
|||
|
||||
if (NULL == ctx.pRes) {
|
||||
indexError("index-filter failed to taosHashInit");
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
||||
|
@ -821,7 +821,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
|||
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||
if (res == NULL) {
|
||||
indexError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
SIF_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
if (res->result != NULL) {
|
||||
taosArrayAddAll(pDst->result, res->result);
|
||||
|
@ -844,7 +844,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
|
|||
ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
if (NULL == ctx.pRes) {
|
||||
indexError("index-filter failed to taosHashInit");
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx);
|
||||
|
@ -856,7 +856,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
|
|||
SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES);
|
||||
if (res == NULL) {
|
||||
indexError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode));
|
||||
SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
SIF_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
*status = res->status;
|
||||
sifFreeParam(res);
|
||||
|
|
|
@ -269,7 +269,7 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
|||
if (ret != 0) {
|
||||
taosArrayDestroy(offsets);
|
||||
indexError("failed to find target tablelist");
|
||||
return TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||
return TSDB_CODE_FILE_CORRUPTED;
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(offsets);
|
||||
|
|
|
@ -132,7 +132,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
char *t = nodesGetStrValueFromNode(colNode);
|
||||
if (NULL == t) {
|
||||
nodesError("fail to get str value from valueNode");
|
||||
NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
NODES_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
||||
int32_t tlen = strlen(t);
|
||||
|
@ -229,5 +229,5 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
|
|||
}
|
||||
|
||||
nodesError("nodesNodeToSQL unknown node = %s", nodesNodeName(pNode->type));
|
||||
NODES_RET(TSDB_CODE_QRY_APP_ERROR);
|
||||
NODES_RET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
|
|
|
@ -1563,7 +1563,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) {
|
|||
pNode->datum.p = (char*)value;
|
||||
break;
|
||||
default:
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -114,7 +114,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
|
|||
if (!isOrdered) {
|
||||
pColList->colIdxInfo = taosMemoryCalloc(pColList->numOfBound, sizeof(SBoundIdxInfo));
|
||||
if (NULL == pColList->colIdxInfo) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SBoundIdxInfo* pColIdx = pColList->colIdxInfo;
|
||||
for (col_id_t i = 0; i < pColList->numOfBound; ++i) {
|
||||
|
@ -150,11 +150,11 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
|
|||
SMsgBuf* msg) {
|
||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||
if (!pTagArray) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
if (!*tagName) {
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue