Merge branch 'feature/3.0_bug16060' of github.com:taosdata/TDengine into feature/3.0_bug16060
This commit is contained in:
commit
cf0b5d878a
|
|
@ -146,6 +146,6 @@ option(
|
||||||
option(
|
option(
|
||||||
BUILD_WITH_INVERTEDINDEX
|
BUILD_WITH_INVERTEDINDEX
|
||||||
"If use invertedIndex"
|
"If use invertedIndex"
|
||||||
OFF
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,20 +71,14 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
|
||||||
#define colDataGetData(p1_, r_) \
|
#define colDataGetData(p1_, r_) \
|
||||||
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
|
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
|
||||||
|
|
||||||
static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData, uint32_t row) {
|
#define IS_JSON_NULL(type,data) ((type) == TSDB_DATA_TYPE_JSON && *(data) == TSDB_DATA_TYPE_NULL)
|
||||||
if (pColumnInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
|
||||||
if (colDataIsNull_var(pColumnInfoData, row)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
char* data = colDataGetVarData(pColumnInfoData, row);
|
|
||||||
return (*data == TSDB_DATA_TYPE_NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData, uint32_t row) {
|
||||||
if (!pColumnInfoData->hasNull) {
|
if (!pColumnInfoData->hasNull) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pColumnInfoData->info.type == TSDB_DATA_TYPE_VARCHAR || pColumnInfoData->info.type == TSDB_DATA_TYPE_NCHAR) {
|
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||||
return colDataIsNull_var(pColumnInfoData, row);
|
return colDataIsNull_var(pColumnInfoData, row);
|
||||||
} else {
|
} else {
|
||||||
if (pColumnInfoData->nullbitmap == NULL) {
|
if (pColumnInfoData->nullbitmap == NULL) {
|
||||||
|
|
@ -186,6 +180,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
||||||
*(double*)p = *(double*)v;
|
*(double*)p = *(double*)v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t getJsonValueLen(const char *data);
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, int32_t* capacity,
|
||||||
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
const SColumnInfoData* pSource, uint32_t numOfRow2);
|
||||||
|
|
@ -230,7 +226,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||||
void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress);
|
void blockCompressEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_t numOfCols, int8_t needCompress);
|
||||||
const char* blockCompressDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData);
|
const char* blockCompressDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRows, const char* pData);
|
||||||
|
|
||||||
void blockDebugShowData(const SArray* dataBlocks);
|
void blockDebugShowData(const SArray* dataBlocks, const char* flag);
|
||||||
|
|
||||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
|
||||||
tb_uid_t suid);
|
tb_uid_t suid);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ typedef struct SValue SValue;
|
||||||
typedef struct SColVal SColVal;
|
typedef struct SColVal SColVal;
|
||||||
typedef struct STSRow2 STSRow2;
|
typedef struct STSRow2 STSRow2;
|
||||||
typedef struct STSRowBuilder STSRowBuilder;
|
typedef struct STSRowBuilder STSRowBuilder;
|
||||||
|
typedef struct SColData SColData;
|
||||||
typedef struct STagVal STagVal;
|
typedef struct STagVal STagVal;
|
||||||
typedef struct STag STag;
|
typedef struct STag STag;
|
||||||
|
|
||||||
|
|
@ -41,6 +42,9 @@ typedef struct STag STag;
|
||||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||||
void tTSchemaDestroy(STSchema *pTSchema);
|
void tTSchemaDestroy(STSchema *pTSchema);
|
||||||
|
|
||||||
|
// SValue
|
||||||
|
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type);
|
||||||
|
|
||||||
// STSRow2
|
// STSRow2
|
||||||
#define COL_VAL_NONE(CID) ((SColVal){.cid = (CID), .isNone = 1})
|
#define COL_VAL_NONE(CID) ((SColVal){.cid = (CID), .isNone = 1})
|
||||||
#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1})
|
#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1})
|
||||||
|
|
@ -166,6 +170,12 @@ struct STag {
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct SColData {
|
||||||
|
int16_t cid;
|
||||||
|
uint32_t nData;
|
||||||
|
uint8_t *pData;
|
||||||
|
};
|
||||||
|
|
||||||
#if 1 //================================================================================================================================================
|
#if 1 //================================================================================================================================================
|
||||||
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
||||||
#define TD_SUPPORT_BITMAP
|
#define TD_SUPPORT_BITMAP
|
||||||
|
|
|
||||||
|
|
@ -1982,6 +1982,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SClientHbKey connKey;
|
SClientHbKey connKey;
|
||||||
|
int64_t clusterId;
|
||||||
SQueryHbReqBasic* query;
|
SQueryHbReqBasic* query;
|
||||||
SHashObj* info; // hash<Skv.key, Skv>
|
SHashObj* info; // hash<Skv.key, Skv>
|
||||||
} SClientHbReq;
|
} SClientHbReq;
|
||||||
|
|
@ -2296,6 +2297,11 @@ typedef struct {
|
||||||
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
int32_t tSerializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||||
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
int32_t tDeserializeSMDropSmaReq(void* buf, int32_t bufLen, SMDropSmaReq* pReq);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t vgId;
|
||||||
|
SEpSet epSet;
|
||||||
|
} SVgEpSet;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t version; // for compatibility(default 0)
|
int8_t version; // for compatibility(default 0)
|
||||||
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
int8_t intervalUnit; // MACRO: TIME_UNIT_XXX
|
||||||
|
|
@ -2305,6 +2311,7 @@ typedef struct {
|
||||||
char indexName[TSDB_INDEX_NAME_LEN];
|
char indexName[TSDB_INDEX_NAME_LEN];
|
||||||
int32_t exprLen;
|
int32_t exprLen;
|
||||||
int32_t tagsFilterLen;
|
int32_t tagsFilterLen;
|
||||||
|
int32_t numOfVgroups;
|
||||||
int64_t indexUid;
|
int64_t indexUid;
|
||||||
tb_uid_t tableUid; // super/child/common table uid
|
tb_uid_t tableUid; // super/child/common table uid
|
||||||
int64_t interval;
|
int64_t interval;
|
||||||
|
|
@ -2312,6 +2319,7 @@ typedef struct {
|
||||||
int64_t sliding;
|
int64_t sliding;
|
||||||
char* expr; // sma expression
|
char* expr; // sma expression
|
||||||
char* tagsFilter;
|
char* tagsFilter;
|
||||||
|
SVgEpSet vgEpSet[];
|
||||||
} STSma; // Time-range-wise SMA
|
} STSma; // Time-range-wise SMA
|
||||||
|
|
||||||
typedef STSma SVCreateTSmaReq;
|
typedef STSma SVCreateTSmaReq;
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_SYSTABLE_RETRIEVE, "retrieve", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_SYSTABLE_RETRIEVE, "retrieve", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GRANT, "grant", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GRANT, "grant", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_AUTH, "auth", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_AUTH, "auth", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CONFIRM_WRITE, "mnode-confirm-write", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_APPLY_MSG, "mnode-apply", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_APPLY_MSG, "mnode-apply-msg", NULL, NULL)
|
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
TD_NEW_MSG_SEG(TDMT_VND_MSG)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp)
|
||||||
|
|
@ -194,13 +193,11 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT_RSMA, "vnode-submit-rsma", SSubmitReq, SSubmitRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_GET_TSMA_EXP_WNDS, "vnode-get-tsma-expired-windows", SVGetTsmaExpWndsReq, SVGetTsmaExpWndsRsp)
|
TD_DEF_MSG_TYPE(TDMT_VND_GET_TSMA_EXP_WNDS, "vnode-get-tsma-expired-windows", SVGetTsmaExpWndsReq, SVGetTsmaExpWndsRsp)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIG, "alter-config", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_REPLICA, "alter-replica", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_START_WRITE, "start-write", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_CONFIRM, "alter-confirm", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_STOP_WRITE, "stop-write", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CONFIRM_WRITE, "confirm-write", NULL, NULL)
|
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DELETE, "delete-data", SVDeleteReq, SVDeleteRsp)
|
|
||||||
|
|
||||||
TD_NEW_MSG_SEG(TDMT_QND_MSG)
|
TD_NEW_MSG_SEG(TDMT_QND_MSG)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ typedef struct SCatalogReq {
|
||||||
SArray *pIndex; // element is index name
|
SArray *pIndex; // element is index name
|
||||||
SArray *pUser; // element is SUserAuthInfo
|
SArray *pUser; // element is SUserAuthInfo
|
||||||
bool qNodeRequired; // valid qnode
|
bool qNodeRequired; // valid qnode
|
||||||
|
bool forceUpdate;
|
||||||
} SCatalogReq;
|
} SCatalogReq;
|
||||||
|
|
||||||
typedef struct SMetaData {
|
typedef struct SMetaData {
|
||||||
|
|
@ -280,7 +281,7 @@ int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||||
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet);
|
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet);
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId);
|
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId, bool forceUpdate);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -193,8 +193,9 @@ void indexInit();
|
||||||
|
|
||||||
/* index filter */
|
/* index filter */
|
||||||
typedef struct SIndexMetaArg {
|
typedef struct SIndexMetaArg {
|
||||||
void* metaHandle;
|
|
||||||
void* metaEx;
|
void* metaEx;
|
||||||
|
void* idx;
|
||||||
|
void* ivtIdx;
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
} SIndexMetaArg;
|
} SIndexMetaArg;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_LOGIC_PLAN_JOIN,
|
QUERY_NODE_LOGIC_PLAN_JOIN,
|
||||||
QUERY_NODE_LOGIC_PLAN_AGG,
|
QUERY_NODE_LOGIC_PLAN_AGG,
|
||||||
QUERY_NODE_LOGIC_PLAN_PROJECT,
|
QUERY_NODE_LOGIC_PLAN_PROJECT,
|
||||||
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF,
|
QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY,
|
||||||
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
QUERY_NODE_LOGIC_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_LOGIC_PLAN_MERGE,
|
QUERY_NODE_LOGIC_PLAN_MERGE,
|
||||||
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
QUERY_NODE_LOGIC_PLAN_WINDOW,
|
||||||
|
|
@ -211,7 +211,8 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_MERGE,
|
QUERY_NODE_PHYSICAL_PLAN_MERGE,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
QUERY_NODE_PHYSICAL_PLAN_SORT,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_SORT_MERGE_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL,
|
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL,
|
||||||
|
|
@ -225,6 +226,7 @@ typedef enum ENodeType {
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC,
|
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
QUERY_NODE_PHYSICAL_PLAN_DISPATCH,
|
||||||
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
QUERY_NODE_PHYSICAL_PLAN_INSERT,
|
||||||
|
QUERY_NODE_PHYSICAL_PLAN_DELETE,
|
||||||
QUERY_NODE_PHYSICAL_SUBPLAN,
|
QUERY_NODE_PHYSICAL_SUBPLAN,
|
||||||
QUERY_NODE_PHYSICAL_PLAN
|
QUERY_NODE_PHYSICAL_PLAN
|
||||||
} ENodeType;
|
} ENodeType;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ typedef struct SScanLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
SNodeList* pScanCols;
|
SNodeList* pScanCols;
|
||||||
SNodeList* pScanPseudoCols;
|
SNodeList* pScanPseudoCols;
|
||||||
struct STableMeta* pMeta;
|
int8_t tableType;
|
||||||
|
uint64_t tableId;
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
EScanType scanType;
|
EScanType scanType;
|
||||||
uint8_t scanSeq[2]; // first is scan count, and second is reverse scan count
|
uint8_t scanSeq[2]; // first is scan count, and second is reverse scan count
|
||||||
|
|
@ -90,12 +91,20 @@ typedef struct SIndefRowsFuncLogicNode {
|
||||||
SNodeList* pVectorFuncs;
|
SNodeList* pVectorFuncs;
|
||||||
} SIndefRowsFuncLogicNode;
|
} SIndefRowsFuncLogicNode;
|
||||||
|
|
||||||
typedef struct SVnodeModifLogicNode {
|
typedef enum EModifyTableType { MODIFY_TABLE_TYPE_INSERT = 1, MODIFY_TABLE_TYPE_DELETE } EModifyTableType;
|
||||||
|
|
||||||
|
typedef struct SVnodeModifyLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
|
EModifyTableType modifyType;
|
||||||
int32_t msgType;
|
int32_t msgType;
|
||||||
SArray* pDataBlocks;
|
SArray* pDataBlocks;
|
||||||
SVgDataBlocks* pVgDataBlocks;
|
SVgDataBlocks* pVgDataBlocks;
|
||||||
} SVnodeModifLogicNode;
|
SNode* pModifyRows; // SColumnNode
|
||||||
|
uint64_t tableId;
|
||||||
|
int8_t tableType; // table type
|
||||||
|
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
STimeWindow deleteTimeRange;
|
||||||
|
} SVnodeModifyLogicNode;
|
||||||
|
|
||||||
typedef struct SExchangeLogicNode {
|
typedef struct SExchangeLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
|
|
@ -111,11 +120,13 @@ typedef struct SMergeLogicNode {
|
||||||
|
|
||||||
typedef enum EWindowType { WINDOW_TYPE_INTERVAL = 1, WINDOW_TYPE_SESSION, WINDOW_TYPE_STATE } EWindowType;
|
typedef enum EWindowType { WINDOW_TYPE_INTERVAL = 1, WINDOW_TYPE_SESSION, WINDOW_TYPE_STATE } EWindowType;
|
||||||
|
|
||||||
typedef enum EStreamIntervalAlgorithm {
|
typedef enum EIntervalAlgorithm {
|
||||||
STREAM_INTERVAL_ALGO_FINAL = 1,
|
INTERVAL_ALGO_HASH = 1,
|
||||||
STREAM_INTERVAL_ALGO_SEMI,
|
INTERVAL_ALGO_SORT_MERGE,
|
||||||
STREAM_INTERVAL_ALGO_SINGLE
|
INTERVAL_ALGO_STREAM_FINAL,
|
||||||
} EStreamIntervalAlgorithm;
|
INTERVAL_ALGO_STREAM_SEMI,
|
||||||
|
INTERVAL_ALGO_STREAM_SINGLE,
|
||||||
|
} EIntervalAlgorithm;
|
||||||
|
|
||||||
typedef struct SWindowLogicNode {
|
typedef struct SWindowLogicNode {
|
||||||
SLogicNode node;
|
SLogicNode node;
|
||||||
|
|
@ -132,7 +143,7 @@ typedef struct SWindowLogicNode {
|
||||||
int8_t triggerType;
|
int8_t triggerType;
|
||||||
int64_t watermark;
|
int64_t watermark;
|
||||||
double filesFactor;
|
double filesFactor;
|
||||||
EStreamIntervalAlgorithm stmInterAlgo;
|
EIntervalAlgorithm intervalAlgo;
|
||||||
} SWindowLogicNode;
|
} SWindowLogicNode;
|
||||||
|
|
||||||
typedef struct SFillLogicNode {
|
typedef struct SFillLogicNode {
|
||||||
|
|
@ -319,6 +330,7 @@ typedef struct SIntervalPhysiNode {
|
||||||
int8_t slidingUnit;
|
int8_t slidingUnit;
|
||||||
} SIntervalPhysiNode;
|
} SIntervalPhysiNode;
|
||||||
|
|
||||||
|
typedef SIntervalPhysiNode SSortMergeIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
|
typedef SIntervalPhysiNode SStreamIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
|
typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode;
|
||||||
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
|
typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode;
|
||||||
|
|
@ -381,6 +393,14 @@ typedef struct SDataInserterNode {
|
||||||
char* pData;
|
char* pData;
|
||||||
} SDataInserterNode;
|
} SDataInserterNode;
|
||||||
|
|
||||||
|
typedef struct SDataDeleterNode {
|
||||||
|
SDataSinkNode sink;
|
||||||
|
uint64_t tableId;
|
||||||
|
int8_t tableType; // table type
|
||||||
|
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
STimeWindow deleteTimeRange;
|
||||||
|
} SDataDeleterNode;
|
||||||
|
|
||||||
typedef struct SSubplan {
|
typedef struct SSubplan {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
SSubplanId id; // unique id of the subplan
|
SSubplanId id; // unique id of the subplan
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
||||||
|| (_type) == TDMT_VND_DROP_TABLE || (_type) == TDMT_VND_DROP_STB)
|
|| (_type) == TDMT_VND_DROP_TABLE || (_type) == TDMT_VND_DROP_STB)
|
||||||
|
|
||||||
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
|
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
|
||||||
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
|
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
|
||||||
|
|
||||||
#define REQUEST_MAX_TRY_TIMES 1
|
#define REQUEST_MAX_TRY_TIMES 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,8 @@ void schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* param
|
||||||
|
|
||||||
int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub);
|
int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub);
|
||||||
|
|
||||||
|
void schedulerStopQueryHb(void *pTrans);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel query job
|
* Cancel query job
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||||
|
|
||||||
//common & util
|
//common & util
|
||||||
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001)
|
#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0003)
|
||||||
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0002)
|
#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0004)
|
||||||
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0003)
|
#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005)
|
||||||
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0010)
|
#define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0010)
|
||||||
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011)
|
#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0011)
|
||||||
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012)
|
#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0012)
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ typedef enum EOperatorType {
|
||||||
OP_TYPE_SUB,
|
OP_TYPE_SUB,
|
||||||
OP_TYPE_MULTI,
|
OP_TYPE_MULTI,
|
||||||
OP_TYPE_DIV,
|
OP_TYPE_DIV,
|
||||||
OP_TYPE_MOD,
|
OP_TYPE_REM,
|
||||||
// unary arithmetic operator
|
// unary arithmetic operator
|
||||||
OP_TYPE_MINUS,
|
OP_TYPE_MINUS,
|
||||||
OP_TYPE_ASSIGN,
|
OP_TYPE_ASSIGN,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ extern "C" {
|
||||||
|
|
||||||
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
|
||||||
#define HEARTBEAT_INTERVAL 1500 // ms
|
#define HEARTBEAT_INTERVAL 1500 // ms
|
||||||
|
|
||||||
#define SYNC_ON_TOP_OF_ASYNC 0
|
#define SYNC_ON_TOP_OF_ASYNC 0
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -58,11 +57,6 @@ enum {
|
||||||
|
|
||||||
typedef struct SAppInstInfo SAppInstInfo;
|
typedef struct SAppInstInfo SAppInstInfo;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void* param;
|
|
||||||
SClientHbReq* req;
|
|
||||||
} SHbConnInfo;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* key;
|
char* key;
|
||||||
// statistics
|
// statistics
|
||||||
|
|
@ -72,11 +66,8 @@ typedef struct {
|
||||||
int64_t startTime;
|
int64_t startTime;
|
||||||
// ctl
|
// ctl
|
||||||
SRWLatch lock; // lock is used in serialization
|
SRWLatch lock; // lock is used in serialization
|
||||||
// connection
|
|
||||||
SAppInstInfo* pAppInstInfo;
|
SAppInstInfo* pAppInstInfo;
|
||||||
// info
|
|
||||||
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
SHashObj* activeInfo; // hash<SClientHbKey, SClientHbReq>
|
||||||
SHashObj* connInfo; // hash<SClientHbKey, SHbConnInfo>
|
|
||||||
} SAppHbMgr;
|
} SAppHbMgr;
|
||||||
|
|
||||||
typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
|
||||||
|
|
@ -326,8 +317,6 @@ void appHbMgrCleanup(void);
|
||||||
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||||
void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey);
|
void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey);
|
||||||
|
|
||||||
int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen);
|
|
||||||
|
|
||||||
// --- mq
|
// --- mq
|
||||||
void hbMgrInitMqHbRspHandle();
|
void hbMgrInitMqHbRspHandle();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,13 @@ void destroyTscObj(void *pObj) {
|
||||||
|
|
||||||
SClientHbKey connKey = {.tscRid = pTscObj->id, .connType = pTscObj->connType};
|
SClientHbKey connKey = {.tscRid = pTscObj->id, .connType = pTscObj->connType};
|
||||||
hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey);
|
hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey);
|
||||||
atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
int64_t connNum = atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||||
closeAllRequests(pTscObj->pRequests);
|
closeAllRequests(pTscObj->pRequests);
|
||||||
|
schedulerStopQueryHb(pTscObj->pAppInfo->pTransporter);
|
||||||
|
if (0 == connNum) {
|
||||||
|
// TODO
|
||||||
|
//closeTransporter(pTscObj);
|
||||||
|
}
|
||||||
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns);
|
||||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||||
taosMemoryFreeClear(pTscObj);
|
taosMemoryFreeClear(pTscObj);
|
||||||
|
|
@ -223,6 +228,10 @@ static void doDestroyRequest(void *p) {
|
||||||
|
|
||||||
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||||
|
|
||||||
|
if (pRequest->body.queryJob != 0) {
|
||||||
|
schedulerFreeJob(pRequest->body.queryJob);
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pRequest->msgBuf);
|
taosMemoryFreeClear(pRequest->msgBuf);
|
||||||
taosMemoryFreeClear(pRequest->sqlstr);
|
taosMemoryFreeClear(pRequest->sqlstr);
|
||||||
taosMemoryFreeClear(pRequest->pDb);
|
taosMemoryFreeClear(pRequest->pDb);
|
||||||
|
|
@ -230,10 +239,6 @@ static void doDestroyRequest(void *p) {
|
||||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||||
qDestroyQueryPlan(pRequest->body.pDag);
|
qDestroyQueryPlan(pRequest->body.pDag);
|
||||||
|
|
||||||
if (pRequest->body.queryJob != 0) {
|
|
||||||
schedulerFreeJob(pRequest->body.queryJob);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(pRequest->tableList);
|
taosArrayDestroy(pRequest->tableList);
|
||||||
taosArrayDestroy(pRequest->dbList);
|
taosArrayDestroy(pRequest->dbList);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,9 +129,9 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey));
|
SClientHbReq *pReq = taosHashGet(pAppHbMgr->activeInfo, &pRsp->connKey, sizeof(SClientHbKey));
|
||||||
if (NULL == info) {
|
if (NULL == pReq) {
|
||||||
tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid,
|
tscWarn("pReq to get activeInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid,
|
||||||
pRsp->connKey.connType);
|
pRsp->connKey.connType);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -181,12 +181,11 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t *clusterId = (int64_t *)info->param;
|
|
||||||
struct SCatalog *pCatalog = NULL;
|
struct SCatalog *pCatalog = NULL;
|
||||||
|
|
||||||
int32_t code = catalogGetHandle(*clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", *clusterId, tstrerror(code));
|
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,12 +198,11 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t *clusterId = (int64_t *)info->param;
|
|
||||||
struct SCatalog *pCatalog = NULL;
|
struct SCatalog *pCatalog = NULL;
|
||||||
|
|
||||||
int32_t code = catalogGetHandle(*clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", *clusterId, tstrerror(code));
|
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,12 +215,11 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t *clusterId = (int64_t *)info->param;
|
|
||||||
struct SCatalog *pCatalog = NULL;
|
struct SCatalog *pCatalog = NULL;
|
||||||
|
|
||||||
int32_t code = catalogGetHandle(*clusterId, &pCatalog);
|
int32_t code = catalogGetHandle(pReq->clusterId, &pCatalog);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", *clusterId, tstrerror(code));
|
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pReq->clusterId, tstrerror(code));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -547,14 +544,11 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||||
|
|
||||||
pOneReq = taosArrayPush(pBatchReq->reqs, pOneReq);
|
pOneReq = taosArrayPush(pBatchReq->reqs, pOneReq);
|
||||||
|
|
||||||
SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pOneReq->connKey, sizeof(SClientHbKey));
|
code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, &pOneReq->clusterId, pOneReq);
|
||||||
if (info) {
|
|
||||||
code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, info->param, pOneReq);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter);
|
pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//hbClearClientHbReq(pOneReq);
|
//hbClearClientHbReq(pOneReq);
|
||||||
|
|
||||||
|
|
@ -569,23 +563,6 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
|
||||||
return pBatchReq;
|
return pBatchReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hbClearReqInfo(SAppHbMgr *pAppHbMgr) {
|
|
||||||
void *pIter = taosHashIterate(pAppHbMgr->activeInfo, NULL);
|
|
||||||
while (pIter != NULL) {
|
|
||||||
SClientHbReq *pOneReq = pIter;
|
|
||||||
|
|
||||||
tFreeReqKvHash(pOneReq->info);
|
|
||||||
taosHashClear(pOneReq->info);
|
|
||||||
|
|
||||||
if (pOneReq->query) {
|
|
||||||
taosArrayDestroy(pOneReq->query->queryDesc);
|
|
||||||
taosMemoryFreeClear(pOneReq->query);
|
|
||||||
}
|
|
||||||
|
|
||||||
pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hbThreadFuncUnexpectedStopped(void) {
|
void hbThreadFuncUnexpectedStopped(void) {
|
||||||
atomic_store_8(&clientHbMgr.threadStop, 2);
|
atomic_store_8(&clientHbMgr.threadStop, 2);
|
||||||
}
|
}
|
||||||
|
|
@ -715,14 +692,6 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
taosHashSetFreeFp(pAppHbMgr->activeInfo, tFreeClientHbReq);
|
||||||
// init getInfoFunc
|
|
||||||
pAppHbMgr->connInfo = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
|
||||||
|
|
||||||
if (pAppHbMgr->connInfo == NULL) {
|
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
taosMemoryFree(pAppHbMgr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
taosThreadMutexLock(&clientHbMgr.lock);
|
taosThreadMutexLock(&clientHbMgr.lock);
|
||||||
taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr);
|
taosArrayPush(clientHbMgr.appHbMgrs, &pAppHbMgr);
|
||||||
|
|
@ -745,15 +714,6 @@ void appHbMgrCleanup(void) {
|
||||||
taosHashCleanup(pTarget->activeInfo);
|
taosHashCleanup(pTarget->activeInfo);
|
||||||
pTarget->activeInfo = NULL;
|
pTarget->activeInfo = NULL;
|
||||||
|
|
||||||
pIter = taosHashIterate(pTarget->connInfo, NULL);
|
|
||||||
while (pIter != NULL) {
|
|
||||||
SHbConnInfo *info = pIter;
|
|
||||||
taosMemoryFree(info->param);
|
|
||||||
pIter = taosHashIterate(pTarget->connInfo, pIter);
|
|
||||||
}
|
|
||||||
taosHashCleanup(pTarget->connInfo);
|
|
||||||
pTarget->connInfo = NULL;
|
|
||||||
|
|
||||||
taosMemoryFree(pTarget->key);
|
taosMemoryFree(pTarget->key);
|
||||||
taosMemoryFree(pTarget);
|
taosMemoryFree(pTarget);
|
||||||
}
|
}
|
||||||
|
|
@ -791,7 +751,7 @@ void hbMgrCleanUp() {
|
||||||
clientHbMgr.appHbMgrs = NULL;
|
clientHbMgr.appHbMgrs = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *info) {
|
int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, int64_t clusterId) {
|
||||||
// init hash in activeinfo
|
// init hash in activeinfo
|
||||||
void *data = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
void *data = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
|
|
@ -799,17 +759,11 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
|
||||||
}
|
}
|
||||||
SClientHbReq hbReq = {0};
|
SClientHbReq hbReq = {0};
|
||||||
hbReq.connKey = connKey;
|
hbReq.connKey = connKey;
|
||||||
|
hbReq.clusterId = clusterId;
|
||||||
//hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
//hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||||
|
|
||||||
taosHashPut(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey), &hbReq, sizeof(SClientHbReq));
|
taosHashPut(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey), &hbReq, sizeof(SClientHbReq));
|
||||||
|
|
||||||
// init hash
|
|
||||||
if (info != NULL) {
|
|
||||||
SClientHbReq *pReq = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
|
||||||
info->req = pReq;
|
|
||||||
taosHashPut(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey), info, sizeof(SHbConnInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
atomic_add_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
atomic_add_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -819,15 +773,10 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, in
|
||||||
.tscRid = tscRefId,
|
.tscRid = tscRefId,
|
||||||
.connType = connType,
|
.connType = connType,
|
||||||
};
|
};
|
||||||
SHbConnInfo info = {0};
|
|
||||||
|
|
||||||
switch (connType) {
|
switch (connType) {
|
||||||
case CONN_TYPE__QUERY: {
|
case CONN_TYPE__QUERY: {
|
||||||
int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t));
|
return hbRegisterConnImpl(pAppHbMgr, connKey, clusterId);
|
||||||
*pClusterId = clusterId;
|
|
||||||
|
|
||||||
info.param = pClusterId;
|
|
||||||
return hbRegisterConnImpl(pAppHbMgr, connKey, &info);
|
|
||||||
}
|
}
|
||||||
case CONN_TYPE__TMQ: {
|
case CONN_TYPE__TMQ: {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -844,26 +793,10 @@ void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) {
|
||||||
taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey));
|
if (NULL == pReq) {
|
||||||
if (info) {
|
|
||||||
taosMemoryFree(info->param);
|
|
||||||
taosHashRemove(pAppHbMgr->connInfo, &connKey, sizeof(SClientHbKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == pReq || NULL == info) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int hbAddConnInfo(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, void *key, void *value, int32_t keyLen,
|
|
||||||
int32_t valueLen) {
|
|
||||||
// find req by connection id
|
|
||||||
SClientHbReq *pReq = taosHashGet(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
|
||||||
ASSERT(pReq != NULL);
|
|
||||||
|
|
||||||
taosHashPut(pReq->info, key, keyLen, value, valueLen);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1234,7 +1234,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
|
||||||
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
||||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||||
} else if (jsonInnerType == TD_TAG_JSON) {
|
} else if (jsonInnerType == TD_TAG_JSON) {
|
||||||
char* jsonString = parseTagDatatoJson(jsonInnerData);
|
char* jsonString = parseTagDatatoJson(pStart);
|
||||||
STR_TO_VARSTR(dst, jsonString);
|
STR_TO_VARSTR(dst, jsonString);
|
||||||
taosMemoryFree(jsonString);
|
taosMemoryFree(jsonString);
|
||||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
taosMemoryFreeClear(output.dbVgroup);
|
taosMemoryFreeClear(output.dbVgroup);
|
||||||
|
|
||||||
tscError("0x%" PRIx64 " failed to build use db output since %s", pRequest->requestId, terrstr());
|
tscError("0x%" PRIx64 " failed to build use db output since %s", pRequest->requestId, terrstr());
|
||||||
} else if (output.dbVgroup) {
|
} else if (output.dbVgroup && output.dbVgroup->vgHash) {
|
||||||
struct SCatalog* pCatalog = NULL;
|
struct SCatalog* pCatalog = NULL;
|
||||||
|
|
||||||
int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||||
|
|
|
||||||
|
|
@ -2332,6 +2332,8 @@ static int32_t isSchemalessDb(SSmlHandle* info){
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "catalogGetDBCfg error, code:", tstrerror(code));
|
smlBuildInvalidDataMsg(&info->msgBuf, "catalogGetDBCfg error, code:", tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
taosArrayDestroy(pInfo.pRetensions);
|
||||||
|
|
||||||
if (!pInfo.schemaless){
|
if (!pInfo.schemaless){
|
||||||
info->pRequest->code = TSDB_CODE_SML_INVALID_DB_CONF;
|
info->pRequest->code = TSDB_CODE_SML_INVALID_DB_CONF;
|
||||||
smlBuildInvalidDataMsg(&info->msgBuf, "can not insert into schemaless db:", dbFname);
|
smlBuildInvalidDataMsg(&info->msgBuf, "can not insert into schemaless db:", dbFname);
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,35 @@ void queryCallback1(void* param, void* res, int32_t code) {
|
||||||
printf("exec query:\n");
|
printf("exec query:\n");
|
||||||
taos_query_a(param, "select * from tm1", queryCallback, param);
|
taos_query_a(param, "select * from tm1", queryCallback, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void createNewTable(TAOS* pConn, int32_t index) {
|
||||||
|
char str[1024] = {0};
|
||||||
|
sprintf(str, "create table tu%d using st2 tags(%d)", index, index);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, str);
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < 1000; i += 20) {
|
||||||
|
char sql[1024] = {0};
|
||||||
|
sprintf(sql,
|
||||||
|
"insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
||||||
|
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
||||||
|
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
||||||
|
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)", index,
|
||||||
|
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
|
||||||
|
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
|
||||||
|
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
|
||||||
|
TAOS_RES* p = taos_query(pConn, sql);
|
||||||
|
if (taos_errno(p) != 0) {
|
||||||
|
printf("failed to insert data, reason:%s\n", taos_errstr(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
taos_free_result(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
@ -590,7 +619,6 @@ TEST(testCase, generated_request_id_test) {
|
||||||
taosHashCleanup(phash);
|
taosHashCleanup(phash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(testCase, insert_test) {
|
TEST(testCase, insert_test) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(pConn, nullptr);
|
ASSERT_NE(pConn, nullptr);
|
||||||
|
|
@ -640,50 +668,10 @@ TEST(testCase, projection_query_tables) {
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
|
|
||||||
pRes = taos_query(pConn, "create table tu2 using st2 tags(1)");
|
for(int32_t i = 0; i < 100; ++i) {
|
||||||
if (taos_errno(pRes) != 0) {
|
printf("create table :%d\n", i);
|
||||||
printf("failed to create table tu, reason:%s\n", taos_errstr(pRes));
|
createNewTable(pConn, i);
|
||||||
}
|
}
|
||||||
taos_free_result(pRes);
|
|
||||||
|
|
||||||
for(int32_t i = 0; i < 1000; i += 20) {
|
|
||||||
char sql[1024] = {0};
|
|
||||||
sprintf(sql,
|
|
||||||
"insert into tu values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
|
|
||||||
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
|
|
||||||
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
|
|
||||||
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
|
|
||||||
TAOS_RES* p = taos_query(pConn, sql);
|
|
||||||
if (taos_errno(p) != 0) {
|
|
||||||
printf("failed to insert data, reason:%s\n", taos_errstr(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("start to insert next table\n");
|
|
||||||
|
|
||||||
// for(int32_t i = 0; i < 1000000; i += 20) {
|
|
||||||
// char sql[1024] = {0};
|
|
||||||
// sprintf(sql,
|
|
||||||
// "insert into tu2 values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
// "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
// "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
|
|
||||||
// "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
|
|
||||||
// i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
|
|
||||||
// i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
|
|
||||||
// i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
|
|
||||||
// TAOS_RES* p = taos_query(pConn, sql);
|
|
||||||
// if (taos_errno(p) != 0) {
|
|
||||||
// printf("failed to insert data, reason:%s\n", taos_errstr(p));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// taos_free_result(p);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pRes = taos_query(pConn, "select * from tu");
|
// pRes = taos_query(pConn, "select * from tu");
|
||||||
// if (taos_errno(pRes) != 0) {
|
// if (taos_errno(pRes) != 0) {
|
||||||
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
|
|
@ -705,74 +693,74 @@ TEST(testCase, projection_query_tables) {
|
||||||
taos_close(pConn);
|
taos_close(pConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(testCase, projection_query_stables) {
|
//TEST(testCase, projection_query_stables) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
ASSERT_NE(pConn, nullptr);
|
// ASSERT_NE(pConn, nullptr);
|
||||||
|
//
|
||||||
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
|
// pRes = taos_query(pConn, "select ts from st1");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
|
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
|
//
|
||||||
|
// char str[512] = {0};
|
||||||
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
|
// printf("%s\n", str);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// taos_free_result(pRes);
|
||||||
|
// taos_close(pConn);
|
||||||
|
//}
|
||||||
|
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
//TEST(testCase, agg_query_tables) {
|
||||||
taos_free_result(pRes);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
// ASSERT_NE(pConn, nullptr);
|
||||||
pRes = taos_query(pConn, "select ts from st1");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
// if (taos_errno(pRes) != 0) {
|
||||||
taos_free_result(pRes);
|
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
||||||
ASSERT_TRUE(false);
|
// taos_free_result(pRes);
|
||||||
}
|
// ASSERT_TRUE(false);
|
||||||
|
// }
|
||||||
TAOS_ROW pRow = NULL;
|
// taos_free_result(pRes);
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
//
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
// pRes = taos_query(pConn, "show stables");
|
||||||
|
// if (taos_errno(pRes) != 0) {
|
||||||
char str[512] = {0};
|
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
// taos_free_result(pRes);
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
// ASSERT_TRUE(false);
|
||||||
printf("%s\n", str);
|
// }
|
||||||
}
|
//
|
||||||
|
// TAOS_ROW pRow = NULL;
|
||||||
taos_free_result(pRes);
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
taos_close(pConn);
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
}
|
//
|
||||||
|
// int32_t n = 0;
|
||||||
TEST(testCase, agg_query_tables) {
|
// char str[512] = {0};
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
ASSERT_NE(pConn, nullptr);
|
// int32_t* length = taos_fetch_lengths(pRes);
|
||||||
|
// for(int32_t i = 0; i < numOfFields; ++i) {
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// printf("(%d):%d " , i, length[i]);
|
||||||
if (taos_errno(pRes) != 0) {
|
// }
|
||||||
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
|
// printf("\n");
|
||||||
taos_free_result(pRes);
|
//
|
||||||
ASSERT_TRUE(false);
|
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
}
|
// printf("%s\n", str);
|
||||||
taos_free_result(pRes);
|
// memset(str, 0, sizeof(str));
|
||||||
|
// }
|
||||||
pRes = taos_query(pConn, "show stables");
|
//
|
||||||
if (taos_errno(pRes) != 0) {
|
// taos_free_result(pRes);
|
||||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
// taos_close(pConn);
|
||||||
taos_free_result(pRes);
|
//}
|
||||||
ASSERT_TRUE(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
TAOS_ROW pRow = NULL;
|
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
|
||||||
|
|
||||||
int32_t n = 0;
|
|
||||||
char str[512] = {0};
|
|
||||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
|
||||||
int32_t* length = taos_fetch_lengths(pRes);
|
|
||||||
for(int32_t i = 0; i < numOfFields; ++i) {
|
|
||||||
printf("(%d):%d " , i, length[i]);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
|
||||||
printf("%s\n", str);
|
|
||||||
memset(str, 0, sizeof(str));
|
|
||||||
}
|
|
||||||
|
|
||||||
taos_free_result(pRes);
|
|
||||||
taos_close(pConn);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,24 @@ void colDataTrim(SColumnInfoData* pColumnInfoData) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t getJsonValueLen(const char *data) {
|
||||||
|
int32_t dataLen = 0;
|
||||||
|
if (*data == TSDB_DATA_TYPE_NULL) {
|
||||||
|
dataLen = CHAR_BYTES;
|
||||||
|
} else if (*data == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
dataLen = varDataTLen(data + CHAR_BYTES) + CHAR_BYTES;
|
||||||
|
} else if (*data == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
dataLen = DOUBLE_BYTES + CHAR_BYTES;
|
||||||
|
} else if (*data == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
dataLen = CHAR_BYTES + CHAR_BYTES;
|
||||||
|
} else if (*data & TD_TAG_JSON) { // json string
|
||||||
|
dataLen = ((STag*)(data))->len;
|
||||||
|
} else {
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
return dataLen;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) {
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) {
|
||||||
ASSERT(pColumnInfoData != NULL);
|
ASSERT(pColumnInfoData != NULL);
|
||||||
|
|
||||||
|
|
@ -118,19 +136,7 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
if (type == TSDB_DATA_TYPE_JSON) {
|
if (type == TSDB_DATA_TYPE_JSON) {
|
||||||
if (*pData == TSDB_DATA_TYPE_NULL) {
|
dataLen = getJsonValueLen(pData);
|
||||||
dataLen = CHAR_BYTES;
|
|
||||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
dataLen = varDataTLen(pData + CHAR_BYTES) + CHAR_BYTES;
|
|
||||||
} else if (*pData == TSDB_DATA_TYPE_DOUBLE) {
|
|
||||||
dataLen = DOUBLE_BYTES + CHAR_BYTES;
|
|
||||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
|
||||||
dataLen = CHAR_BYTES + CHAR_BYTES;
|
|
||||||
} else if (*pData == TD_TAG_JSON) { // json string
|
|
||||||
dataLen = ((STag*)(pData))->len;
|
|
||||||
} else {
|
|
||||||
ASSERT(0);
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
dataLen = varDataTLen(pData);
|
dataLen = varDataTLen(pData);
|
||||||
}
|
}
|
||||||
|
|
@ -1482,7 +1488,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockDebugShowData(const SArray* dataBlocks) {
|
void blockDebugShowData(const SArray* dataBlocks, const char* flag) {
|
||||||
char pBuf[128] = {0};
|
char pBuf[128] = {0};
|
||||||
int32_t sz = taosArrayGetSize(dataBlocks);
|
int32_t sz = taosArrayGetSize(dataBlocks);
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
|
@ -1490,7 +1496,7 @@ void blockDebugShowData(const SArray* dataBlocks) {
|
||||||
int32_t colNum = pDataBlock->info.numOfCols;
|
int32_t colNum = pDataBlock->info.numOfCols;
|
||||||
int32_t rows = pDataBlock->info.rows;
|
int32_t rows = pDataBlock->info.rows;
|
||||||
for (int32_t j = 0; j < rows; j++) {
|
for (int32_t j = 0; j < rows; j++) {
|
||||||
printf("|");
|
printf("%s |", flag);
|
||||||
for (int32_t k = 0; k < colNum; k++) {
|
for (int32_t k = 0; k < colNum; k++) {
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||||
|
|
@ -1515,8 +1521,11 @@ void blockDebugShowData(const SArray* dataBlocks) {
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
printf(" %15lu |", *(uint64_t*)var);
|
printf(" %15lu |", *(uint64_t*)var);
|
||||||
break;
|
break;
|
||||||
|
case TSDB_DATA_TYPE_FLOAT:
|
||||||
|
printf(" %15f |", *(float*)var);
|
||||||
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE:
|
case TSDB_DATA_TYPE_DOUBLE:
|
||||||
printf(" %15f |", *(double*)var);
|
printf(" %15lf |", *(double*)var);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1544,8 +1553,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
bufSize += sizeof(SSubmitBlk);
|
bufSize += sizeof(SSubmitBlk);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(bufSize < 3 * 1024 * 1024);
|
|
||||||
|
|
||||||
*pReq = taosMemoryCalloc(1, bufSize);
|
*pReq = taosMemoryCalloc(1, bufSize);
|
||||||
if (!(*pReq)) {
|
if (!(*pReq)) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
@ -1556,7 +1563,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
int32_t msgLen = sizeof(SSubmitReq);
|
int32_t msgLen = sizeof(SSubmitReq);
|
||||||
int32_t numOfBlks = 0;
|
int32_t numOfBlks = 0;
|
||||||
SRowBuilder rb = {0};
|
SRowBuilder rb = {0};
|
||||||
tdSRowInit(&rb, pTSchema->version); // TODO: use the latest version
|
tdSRowInit(&rb, pTSchema->version);
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; ++i) {
|
for (int32_t i = 0; i < sz; ++i) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
|
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
|
||||||
|
|
@ -1574,17 +1581,16 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
pSubmitBlk->uid = pDataBlock->info.groupId;
|
pSubmitBlk->uid = pDataBlock->info.groupId;
|
||||||
pSubmitBlk->numOfRows = rows;
|
pSubmitBlk->numOfRows = rows;
|
||||||
|
|
||||||
++numOfBlks;
|
|
||||||
|
|
||||||
msgLen += sizeof(SSubmitBlk);
|
msgLen += sizeof(SSubmitBlk);
|
||||||
int32_t dataLen = 0;
|
int32_t dataLen = 0;
|
||||||
for (int32_t j = 0; j < rows; ++j) { // iterate by row
|
for (int32_t j = 0; j < rows; ++j) { // iterate by row
|
||||||
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf
|
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf
|
||||||
printf("|");
|
|
||||||
bool isStartKey = false;
|
bool isStartKey = false;
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
for (int32_t k = 0; k < colNum; ++k) { // iterate by column
|
for (int32_t k = 0; k < colNum; ++k) { // iterate by column
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||||
|
STColumn* pCol = &pTSchema->columns[k];
|
||||||
|
ASSERT(pCol->type == pColInfoData->info.type);
|
||||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||||
switch (pColInfoData->info.type) {
|
switch (pColInfoData->info.type) {
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
|
@ -1594,29 +1600,29 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
offset, k);
|
offset, k);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, offset, k);
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true, offset, k);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true, offset, k);
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true, offset, k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||||
tdAppendColValToRow(&rb, 2, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true, offset, k);
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true, offset, k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
case TSDB_DATA_TYPE_DECIMAL:
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
case TSDB_DATA_TYPE_BLOB:
|
case TSDB_DATA_TYPE_BLOB:
|
||||||
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
case TSDB_DATA_TYPE_MEDIUMBLOB:
|
||||||
printf("the column type %" PRIi16 " is defined but not implemented yet\n", pColInfoData->info.type);
|
uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type);
|
||||||
TASSERT(0);
|
TASSERT(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
|
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
|
||||||
tdAppendColValToRow(&rb, 2, pColInfoData->info.type, TD_VTYPE_NORM, var, true, offset, k);
|
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pColInfoData->info.type, TD_VTYPE_NORM, var, true, offset, k);
|
||||||
} else {
|
} else {
|
||||||
printf("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
|
uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
|
||||||
TASSERT(0);
|
TASSERT(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1624,7 +1630,13 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
|
||||||
offset += TYPE_BYTES[pColInfoData->info.type];
|
offset += TYPE_BYTES[pColInfoData->info.type];
|
||||||
}
|
}
|
||||||
dataLen += TD_ROW_LEN(rb.pBuf);
|
dataLen += TD_ROW_LEN(rb.pBuf);
|
||||||
|
#ifdef TD_DEBUG_PRINT_ROW
|
||||||
|
tdSRowPrint(rb.pBuf, pTSchema, __func__);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++numOfBlks;
|
||||||
|
|
||||||
pSubmitBlk->dataLen = dataLen;
|
pSubmitBlk->dataLen = dataLen;
|
||||||
msgLen += pSubmitBlk->dataLen;
|
msgLen += pSubmitBlk->dataLen;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ typedef struct {
|
||||||
#define GET_BIT1(p, i) (((p)[(i) / 8] >> ((i) % 8)) & ((uint8_t)1))
|
#define GET_BIT1(p, i) (((p)[(i) / 8] >> ((i) % 8)) & ((uint8_t)1))
|
||||||
#define GET_BIT2(p, i) (((p)[(i) / 4] >> ((i) % 4)) & ((uint8_t)3))
|
#define GET_BIT2(p, i) (((p)[(i) / 4] >> ((i) % 4)) & ((uint8_t)3))
|
||||||
|
|
||||||
static FORCE_INLINE int tSKVIdxCmprFn(const void *p1, const void *p2);
|
|
||||||
|
|
||||||
// SValue
|
// SValue
|
||||||
static FORCE_INLINE int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
|
static FORCE_INLINE int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
@ -141,6 +139,11 @@ static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type) {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// STSRow2 ========================================================================
|
// STSRow2 ========================================================================
|
||||||
static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
|
static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
|
||||||
if (pb) {
|
if (pb) {
|
||||||
|
|
|
||||||
|
|
@ -3661,6 +3661,7 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
|
||||||
if (tEncodeCStr(pCoder, pSma->indexName) < 0) return -1;
|
if (tEncodeCStr(pCoder, pSma->indexName) < 0) return -1;
|
||||||
if (tEncodeI32(pCoder, pSma->exprLen) < 0) return -1;
|
if (tEncodeI32(pCoder, pSma->exprLen) < 0) return -1;
|
||||||
if (tEncodeI32(pCoder, pSma->tagsFilterLen) < 0) return -1;
|
if (tEncodeI32(pCoder, pSma->tagsFilterLen) < 0) return -1;
|
||||||
|
if (tEncodeI32(pCoder, pSma->numOfVgroups) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pSma->indexUid) < 0) return -1;
|
if (tEncodeI64(pCoder, pSma->indexUid) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pSma->tableUid) < 0) return -1;
|
if (tEncodeI64(pCoder, pSma->tableUid) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pSma->interval) < 0) return -1;
|
if (tEncodeI64(pCoder, pSma->interval) < 0) return -1;
|
||||||
|
|
@ -3672,7 +3673,17 @@ int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) {
|
||||||
if (pSma->tagsFilterLen > 0) {
|
if (pSma->tagsFilterLen > 0) {
|
||||||
if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1;
|
if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1;
|
||||||
}
|
}
|
||||||
|
for (int32_t v = 0; v < pSma->numOfVgroups; ++v) {
|
||||||
|
if (tEncodeI32(pCoder, pSma->vgEpSet[v].vgId) < 0) return -1;
|
||||||
|
if (tEncodeI8(pCoder, pSma->vgEpSet[v].epSet.inUse) < 0) return -1;
|
||||||
|
int8_t numOfEps = pSma->vgEpSet[v].epSet.numOfEps;
|
||||||
|
if (tEncodeI8(pCoder, numOfEps) < 0) return -1;
|
||||||
|
for (int32_t n = 0; n < numOfEps; ++n) {
|
||||||
|
const SEp *pEp = &pSma->vgEpSet[v].epSet.eps[n];
|
||||||
|
if (tEncodeCStr(pCoder, pEp->fqdn) < 0) return -1;
|
||||||
|
if (tEncodeU16(pCoder, pEp->port) < 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3685,6 +3696,7 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
||||||
if (tDecodeCStrTo(pCoder, pSma->indexName) < 0) return -1;
|
if (tDecodeCStrTo(pCoder, pSma->indexName) < 0) return -1;
|
||||||
if (tDecodeI32(pCoder, &pSma->exprLen) < 0) return -1;
|
if (tDecodeI32(pCoder, &pSma->exprLen) < 0) return -1;
|
||||||
if (tDecodeI32(pCoder, &pSma->tagsFilterLen) < 0) return -1;
|
if (tDecodeI32(pCoder, &pSma->tagsFilterLen) < 0) return -1;
|
||||||
|
if (tDecodeI32(pCoder, &pSma->numOfVgroups) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1;
|
||||||
if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1;
|
if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1;
|
||||||
|
|
@ -3700,6 +3712,17 @@ int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma) {
|
||||||
} else {
|
} else {
|
||||||
pSma->tagsFilter = NULL;
|
pSma->tagsFilter = NULL;
|
||||||
}
|
}
|
||||||
|
for (int32_t v = 0; v < pSma->numOfVgroups; ++v) {
|
||||||
|
if (tDecodeI32(pCoder, &pSma->vgEpSet[v].vgId) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pSma->vgEpSet[v].epSet.inUse) < 0) return -1;
|
||||||
|
if (tDecodeI8(pCoder, &pSma->vgEpSet[v].epSet.numOfEps) < 0) return -1;
|
||||||
|
int8_t numOfEps = pSma->vgEpSet[v].epSet.numOfEps;
|
||||||
|
for (int32_t n = 0; n < numOfEps; ++n) {
|
||||||
|
SEp *pEp = &pSma->vgEpSet[v].epSet.eps[n];
|
||||||
|
if (tDecodeCStrTo(pCoder, pEp->fqdn) < 0) return -1;
|
||||||
|
if (tDecodeU16(pCoder, &pEp->port) < 0) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,6 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutNodeMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIRM_WRITE, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_CONTINUE, mmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
@ -214,6 +213,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TASK_DEPLOY_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutNodeMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutNodeMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,7 @@ SArray *vmGetMsgHandles() {
|
||||||
|
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
||||||
|
|
@ -118,25 +118,36 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
|
||||||
pMsg = *(SRpcMsg **)taosArrayGet(pArray, m);
|
pMsg = *(SRpcMsg **)taosArrayGet(pArray, m);
|
||||||
code = vnodePreprocessReq(pVnode->pImpl, pMsg);
|
code = vnodePreprocessReq(pVnode->pImpl, pMsg);
|
||||||
|
|
||||||
if (code == TSDB_CODE_ACTION_IN_PROGRESS) continue;
|
if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||||
if (code != 0) {
|
dTrace("vgId:%d, msg:%p in progress and no rsp", pVnode->vgId, pMsg);
|
||||||
dError("vgId:%d, msg:%p failed to write since %s", pVnode->vgId, pMsg, tstrerror(code));
|
|
||||||
vmSendRsp(pMsg, code);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pMsg->msgType != TDMT_VND_ALTER_REPLICA) {
|
||||||
code = syncPropose(sync, pMsg, false);
|
code = syncPropose(sync, pMsg, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (code == TAOS_SYNC_PROPOSE_SUCCESS) {
|
if (code == TAOS_SYNC_PROPOSE_SUCCESS) {
|
||||||
|
dTrace("vgId:%d, msg:%p is proposed and no rsp", pVnode->vgId, pMsg);
|
||||||
continue;
|
continue;
|
||||||
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
} else if (code == TAOS_SYNC_PROPOSE_NOT_LEADER) {
|
||||||
dTrace("vgId:%d, msg:%p is redirect since not leader", pVnode->vgId, pMsg);
|
|
||||||
SEpSet newEpSet = {0};
|
SEpSet newEpSet = {0};
|
||||||
syncGetEpSet(sync, &newEpSet);
|
syncGetEpSet(sync, &newEpSet);
|
||||||
|
SEp *pEp = &newEpSet.eps[newEpSet.inUse];
|
||||||
|
if (pEp->port == tsServerPort && strcmp(pEp->fqdn, tsLocalFqdn) == 0) {
|
||||||
newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps;
|
newEpSet.inUse = (newEpSet.inUse + 1) % newEpSet.numOfEps;
|
||||||
|
}
|
||||||
|
|
||||||
|
dTrace("vgId:%d, msg:%p is redirect since not leader, numOfEps:%d inUse:%d", pVnode->vgId, pMsg,
|
||||||
|
newEpSet.numOfEps, newEpSet.inUse);
|
||||||
|
for (int32_t i = 0; i < newEpSet.numOfEps; ++i) {
|
||||||
|
dTrace("vgId:%d, msg:%p ep:%s:%u", pVnode->vgId, pMsg, newEpSet.eps[i].fqdn, newEpSet.eps[i].port);
|
||||||
|
}
|
||||||
|
|
||||||
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info};
|
||||||
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
tmsgSendRedirectRsp(&rsp, &newEpSet);
|
||||||
} else {
|
} else {
|
||||||
dError("vgId:%d, msg:%p failed to write since %s", pVnode->vgId, pMsg, tstrerror(code));
|
dError("vgId:%d, msg:%p failed to propose write since %s, code:0x%x", pVnode->vgId, pMsg, tstrerror(code), code);
|
||||||
vmSendRsp(pMsg, code);
|
vmSendRsp(pMsg, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +262,6 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
||||||
switch (qtype) {
|
switch (qtype) {
|
||||||
case QUERY_QUEUE:
|
case QUERY_QUEUE:
|
||||||
vnodePreprocessQueryMsg(pVnode->pImpl, pMsg);
|
vnodePreprocessQueryMsg(pVnode->pImpl, pMsg);
|
||||||
|
|
||||||
dTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg);
|
dTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg);
|
||||||
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
taosWriteQitem(pVnode->pQueryQ, pMsg);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,18 @@ typedef enum {
|
||||||
TRANS_STOP_FUNC_MQ_REB = 4,
|
TRANS_STOP_FUNC_MQ_REB = 4,
|
||||||
} ETrnFunc;
|
} ETrnFunc;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TRANS_ACTION_NULL = 0,
|
||||||
|
TRANS_ACTION_MSG = 1,
|
||||||
|
TRANS_ACTION_RAW = 2,
|
||||||
|
} ETrnAct;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t id;
|
int32_t id;
|
||||||
int32_t errCode;
|
int32_t errCode;
|
||||||
int32_t acceptableCode;
|
int32_t acceptableCode;
|
||||||
int8_t stage;
|
int8_t stage;
|
||||||
int8_t actionType; // 0-msg, 1-raw
|
ETrnAct actionType;
|
||||||
int8_t rawWritten;
|
int8_t rawWritten;
|
||||||
int8_t msgSent;
|
int8_t msgSent;
|
||||||
int8_t msgReceived;
|
int8_t msgReceived;
|
||||||
|
|
@ -57,6 +63,7 @@ void mndTransDrop(STrans *pTrans);
|
||||||
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
|
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw);
|
||||||
|
int32_t mndTransAppendNullLog(STrans *pTrans);
|
||||||
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
|
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
|
||||||
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
|
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction);
|
||||||
void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen);
|
void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen);
|
||||||
|
|
@ -65,7 +72,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname);
|
||||||
void mndTransSetSerial(STrans *pTrans);
|
void mndTransSetSerial(STrans *pTrans);
|
||||||
|
|
||||||
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans);
|
||||||
void mndTransProcessRsp(SRpcMsg *pRsp);
|
int32_t mndTransProcessRsp(SRpcMsg *pRsp);
|
||||||
void mndTransPullup(SMnode *pMnode);
|
void mndTransPullup(SMnode *pMnode);
|
||||||
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
|
int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ int32_t mndAllocSmaVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup);
|
||||||
int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups);
|
int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups);
|
||||||
SArray *mndBuildDnodesArray(SMnode *pMnode);
|
SArray *mndBuildDnodesArray(SMnode *pMnode);
|
||||||
int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray);
|
int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray);
|
||||||
int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray, SVnodeGid *del1, SVnodeGid *del2);
|
int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pVgId);
|
||||||
|
|
||||||
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen, bool standby);
|
void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen, bool standby);
|
||||||
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen);
|
||||||
|
|
|
||||||
|
|
@ -30,25 +30,25 @@ static int32_t mndBnodeActionInsert(SSdb *pSdb, SBnodeObj *pObj);
|
||||||
static int32_t mndBnodeActionUpdate(SSdb *pSdb, SBnodeObj *pOld, SBnodeObj *pNew);
|
static int32_t mndBnodeActionUpdate(SSdb *pSdb, SBnodeObj *pOld, SBnodeObj *pNew);
|
||||||
static int32_t mndBnodeActionDelete(SSdb *pSdb, SBnodeObj *pObj);
|
static int32_t mndBnodeActionDelete(SSdb *pSdb, SBnodeObj *pObj);
|
||||||
static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCreateBnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropBnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndRetrieveBnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveBnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextBnode(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextBnode(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitBnode(SMnode *pMnode) {
|
int32_t mndInitBnode(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_BNODE,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_BNODE,
|
||||||
.keyType = SDB_KEY_INT32,
|
.keyType = SDB_KEY_INT32,
|
||||||
.encodeFp = (SdbEncodeFp)mndBnodeActionEncode,
|
.encodeFp = (SdbEncodeFp)mndBnodeActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndBnodeActionDecode,
|
.decodeFp = (SdbDecodeFp)mndBnodeActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndBnodeActionInsert,
|
.insertFp = (SdbInsertFp)mndBnodeActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndBnodeActionUpdate,
|
.updateFp = (SdbUpdateFp)mndBnodeActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndBnodeActionDelete};
|
.deleteFp = (SdbDeleteFp)mndBnodeActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_BNODE, mndProcessCreateBnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_BNODE, mndProcessCreateBnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_BNODE, mndProcessDropBnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_BNODE, mndProcessDropBnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_BNODE_RSP, mndProcessCreateBnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_BNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_BNODE_RSP, mndProcessDropBnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_BNODE_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_BNODE, mndRetrieveBnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_BNODE, mndRetrieveBnodes);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_BNODE, mndCancelGetNextBnode);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_BNODE, mndCancelGetNextBnode);
|
||||||
|
|
@ -427,16 +427,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateBnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDropBnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveBnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveBnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,8 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb) {
|
||||||
sdbRelease(pSdb, pDb);
|
sdbRelease(pSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool standby) {
|
static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid,
|
||||||
|
bool standby) {
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
|
|
||||||
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId);
|
||||||
|
|
@ -288,6 +289,32 @@ static int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *p
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
|
STransAction action = {0};
|
||||||
|
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
|
||||||
|
int32_t contLen = sizeof(SMsgHead);
|
||||||
|
SMsgHead *pHead = taosMemoryMalloc(contLen);
|
||||||
|
if (pHead == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pHead->contLen = htonl(contLen);
|
||||||
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
|
action.pCont = pHead;
|
||||||
|
action.contLen = contLen;
|
||||||
|
action.msgType = TDMT_VND_ALTER_CONFIRM;
|
||||||
|
|
||||||
|
if (mndTransAppendRedoAction(pTrans, &action) != 0) {
|
||||||
|
taosMemoryFree(pHead);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType) {
|
static int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, tmsg_t msgType) {
|
||||||
STransAction action = {0};
|
STransAction action = {0};
|
||||||
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
action.epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||||
|
|
@ -415,7 +442,6 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
if (pCfg->cacheLastRow < 0) pCfg->cacheLastRow = TSDB_DEFAULT_CACHE_LAST_ROW;
|
||||||
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
|
if (pCfg->numOfRetensions < 0) pCfg->numOfRetensions = 0;
|
||||||
if (pCfg->schemaless < 0) pCfg->schemaless = TSDB_DB_SCHEMALESS_OFF;
|
if (pCfg->schemaless < 0) pCfg->schemaless = TSDB_DB_SCHEMALESS_OFF;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) {
|
static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) {
|
||||||
|
|
@ -726,30 +752,32 @@ static int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj
|
||||||
mndTransSetSerial(pTrans);
|
mndTransSetSerial(pTrans);
|
||||||
|
|
||||||
if (newVgroup.replica < pDb->cfg.replications) {
|
if (newVgroup.replica < pDb->cfg.replications) {
|
||||||
mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId,
|
mInfo("db:%s, vgId:%d, vn:0 dnode:%d, will add 2 vnodes", pVgroup->dbName, pVgroup->vgId,
|
||||||
pVgroup->vnodeGid[0].dnodeId);
|
pVgroup->vnodeGid[0].dnodeId);
|
||||||
|
|
||||||
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) {
|
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||||
mError("db:%s, failed to add vnode to vgId:%d since %s", pDb->name, newVgroup.vgId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
newVgroup.replica = pDb->cfg.replications;
|
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[1], true) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
|
|
||||||
|
if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1;
|
||||||
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2], true) != 0) return -1;
|
if (mndAddCreateVnodeAction(pMnode, pTrans, pDb, &newVgroup, &newVgroup.vnodeGid[2], true) != 0) return -1;
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
} else {
|
} else {
|
||||||
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
mInfo("db:%s, vgId:%d, will remove 2 vnodes", pVgroup->dbName, pVgroup->vgId);
|
||||||
|
|
||||||
SVnodeGid del1 = {0};
|
SVnodeGid del1 = {0};
|
||||||
SVnodeGid del2 = {0};
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1;
|
||||||
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1, &del2) != 0) {
|
|
||||||
mError("db:%s, failed to remove vnode from vgId:%d since %s", pDb->name, newVgroup.vgId, terrstr());
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
newVgroup.replica = pDb->cfg.replications;
|
|
||||||
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del1, true) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
|
|
||||||
|
SVnodeGid del2 = {0};
|
||||||
|
if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeAction(pMnode, pTrans, pDb, &newVgroup, TDMT_VND_ALTER_REPLICA) != 0) return -1;
|
||||||
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVgroup, &del2, true) != 0) return -1;
|
||||||
|
if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVgroup) != 0) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup);
|
SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup);
|
||||||
|
|
@ -1341,7 +1369,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
||||||
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
int32_t numOfTable = mndGetDBTableNum(pDb, pMnode);
|
||||||
|
|
||||||
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable) {
|
if (pDbVgVersion->vgVersion >= pDb->vgVersion && numOfTable == pDbVgVersion->numOfTable) {
|
||||||
mDebug("db:%s, version & numOfTable not changed", pDbVgVersion->dbFName);
|
mDebug("db:%s, version and numOfTable not changed", pDbVgVersion->dbFName);
|
||||||
mndReleaseDb(pMnode, pDb);
|
mndReleaseDb(pMnode, pDb);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1434,11 +1462,21 @@ const char *mndGetDbStr(const char *src) {
|
||||||
int64_t getValOfDiffPrecision(int8_t unit, int64_t val) {
|
int64_t getValOfDiffPrecision(int8_t unit, int64_t val) {
|
||||||
int64_t v = 0;
|
int64_t v = 0;
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case 's': v = val / 1000; break;
|
case 's':
|
||||||
case 'm': v = val / tsTickPerMin[TSDB_TIME_PRECISION_MILLI]; break;
|
v = val / 1000;
|
||||||
case 'h': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 60); break;
|
break;
|
||||||
case 'd': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60); break;
|
case 'm':
|
||||||
case 'w': v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60 * 7); break;
|
v = val / tsTickPerMin[TSDB_TIME_PRECISION_MILLI];
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 60);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60);
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60 * 7);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,6 @@ static int32_t mndMnodeActionUpdate(SSdb *pSdb, SMnodeObj *pOld, SMnodeObj *pNe
|
||||||
static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCreateMnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessAlterMnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessDropMnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
|
|
@ -53,11 +50,11 @@ int32_t mndInitMnode(SMnode *pMnode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_MNODE, mndProcessCreateMnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_MNODE, mndProcessCreateMnodeReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE, mndProcessAlterMnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE, mndProcessAlterMnodeReq);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_MNODE, mndProcessDropMnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_MNODE_RSP, mndProcessCreateMnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_MNODE_RSP, mndProcessAlterMnodeRsp);
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_MNODE_RSP, mndProcessDropMnodeRsp);
|
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndRetrieveMnodes);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_MNODE, mndCancelGetNextMnode);
|
||||||
|
|
@ -367,7 +364,7 @@ static int32_t mndCreateMnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode,
|
||||||
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER;
|
||||||
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER;
|
||||||
|
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
@ -549,6 +546,7 @@ static int32_t mndDropMnode(SMnode *pMnode, SRpcMsg *pReq, SMnodeObj *pObj) {
|
||||||
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||||
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) goto _OVER;
|
||||||
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) goto _OVER;
|
if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) goto _OVER;
|
||||||
|
if (mndTransAppendNullLog(pTrans) != 0) goto _OVER;
|
||||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
@ -616,21 +614,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateMnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessAlterMnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDropMnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
||||||
|
|
@ -30,26 +30,26 @@ static int32_t mndQnodeActionInsert(SSdb *pSdb, SQnodeObj *pObj);
|
||||||
static int32_t mndQnodeActionUpdate(SSdb *pSdb, SQnodeObj *pOld, SQnodeObj *pNew);
|
static int32_t mndQnodeActionUpdate(SSdb *pSdb, SQnodeObj *pOld, SQnodeObj *pNew);
|
||||||
static int32_t mndQnodeActionDelete(SSdb *pSdb, SQnodeObj *pObj);
|
static int32_t mndQnodeActionDelete(SSdb *pSdb, SQnodeObj *pObj);
|
||||||
static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCreateQnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropQnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessQnodeListReq(SRpcMsg *pReq);
|
static int32_t mndProcessQnodeListReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextQnode(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextQnode(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitQnode(SMnode *pMnode) {
|
int32_t mndInitQnode(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_QNODE,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_QNODE,
|
||||||
.keyType = SDB_KEY_INT32,
|
.keyType = SDB_KEY_INT32,
|
||||||
.encodeFp = (SdbEncodeFp)mndQnodeActionEncode,
|
.encodeFp = (SdbEncodeFp)mndQnodeActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndQnodeActionDecode,
|
.decodeFp = (SdbDecodeFp)mndQnodeActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndQnodeActionInsert,
|
.insertFp = (SdbInsertFp)mndQnodeActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndQnodeActionUpdate,
|
.updateFp = (SdbUpdateFp)mndQnodeActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndQnodeActionDelete};
|
.deleteFp = (SdbDeleteFp)mndQnodeActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_QNODE, mndProcessCreateQnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_QNODE, mndProcessCreateQnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_QNODE, mndProcessDropQnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_QNODE, mndProcessDropQnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_QNODE_RSP, mndProcessCreateQnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_QNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_QNODE_RSP, mndProcessDropQnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_QNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_QNODE_LIST, mndProcessQnodeListReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_QNODE_LIST, mndProcessQnodeListReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QNODE, mndRetrieveQnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QNODE, mndRetrieveQnodes);
|
||||||
|
|
@ -503,16 +503,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateQnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDropQnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
||||||
|
|
@ -38,25 +38,25 @@ static int32_t mndSmaActionDelete(SSdb *pSdb, SSmaObj *pSpSmatb);
|
||||||
static int32_t mndSmaActionUpdate(SSdb *pSdb, SSmaObj *pOld, SSmaObj *pNew);
|
static int32_t mndSmaActionUpdate(SSdb *pSdb, SSmaObj *pOld, SSmaObj *pNew);
|
||||||
static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessMCreateSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessMDropSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessVCreateSmaRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessVDropSmaRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessGetSmaReq(SRpcMsg *pReq);
|
static int32_t mndProcessGetSmaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextSma(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitSma(SMnode *pMnode) {
|
int32_t mndInitSma(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_SMA,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_SMA,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
.encodeFp = (SdbEncodeFp)mndSmaActionEncode,
|
.encodeFp = (SdbEncodeFp)mndSmaActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndSmaActionDecode,
|
.decodeFp = (SdbDecodeFp)mndSmaActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndSmaActionInsert,
|
.insertFp = (SdbInsertFp)mndSmaActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndSmaActionUpdate,
|
.updateFp = (SdbUpdateFp)mndSmaActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndSmaActionDelete};
|
.deleteFp = (SdbDeleteFp)mndSmaActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessMCreateSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SMA, mndProcessMCreateSmaReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessMDropSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SMA, mndProcessMDropSmaReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_SMA_RSP, mndProcessVCreateSmaRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_SMA_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_SMA_RSP, mndProcessVDropSmaRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_DROP_SMA_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetSmaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_GET_INDEX, mndProcessGetSmaReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndRetrieveSma);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndRetrieveSma);
|
||||||
|
|
@ -637,11 +637,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVCreateSmaRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndSetDropSmaRedoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *pSma) {
|
static int32_t mndSetDropSmaRedoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *pSma) {
|
||||||
SSdbRaw *pRedoRaw = mndSmaActionEncode(pSma);
|
SSdbRaw *pRedoRaw = mndSmaActionEncode(pSma);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
|
|
@ -910,11 +905,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVDropSmaRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
||||||
|
|
@ -30,25 +30,25 @@ static int32_t mndSnodeActionInsert(SSdb *pSdb, SSnodeObj *pObj);
|
||||||
static int32_t mndSnodeActionUpdate(SSdb *pSdb, SSnodeObj *pOld, SSnodeObj *pNew);
|
static int32_t mndSnodeActionUpdate(SSdb *pSdb, SSnodeObj *pOld, SSnodeObj *pNew);
|
||||||
static int32_t mndSnodeActionDelete(SSdb *pSdb, SSnodeObj *pObj);
|
static int32_t mndSnodeActionDelete(SSdb *pSdb, SSnodeObj *pObj);
|
||||||
static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessCreateSnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropSnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextSnode(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextSnode(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitSnode(SMnode *pMnode) {
|
int32_t mndInitSnode(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_SNODE,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_SNODE,
|
||||||
.keyType = SDB_KEY_INT32,
|
.keyType = SDB_KEY_INT32,
|
||||||
.encodeFp = (SdbEncodeFp)mndSnodeActionEncode,
|
.encodeFp = (SdbEncodeFp)mndSnodeActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndSnodeActionDecode,
|
.decodeFp = (SdbDecodeFp)mndSnodeActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndSnodeActionInsert,
|
.insertFp = (SdbInsertFp)mndSnodeActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndSnodeActionUpdate,
|
.updateFp = (SdbUpdateFp)mndSnodeActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndSnodeActionDelete};
|
.deleteFp = (SdbDeleteFp)mndSnodeActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SNODE, mndProcessCreateSnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_SNODE, mndProcessCreateSnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SNODE, mndProcessDropSnodeReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_SNODE, mndProcessDropSnodeReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_SNODE_RSP, mndProcessCreateSnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_SNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_SNODE_RSP, mndProcessDropSnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_SNODE_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_SNODE, mndRetrieveSnodes);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_SNODE, mndRetrieveSnodes);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_SNODE, mndCancelGetNextSnode);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_SNODE, mndCancelGetNextSnode);
|
||||||
|
|
@ -437,16 +437,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateSnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDropSnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew);
|
||||||
static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessMCreateStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessMAlterStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessMDropStbReq(SRpcMsg *pReq);
|
static int32_t mndProcessMDropStbReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessVCreateStbRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessVAlterStbRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessVDropStbRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
|
||||||
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStb(SMnode *pMnode, void *pIter);
|
||||||
|
|
@ -59,9 +56,9 @@ int32_t mndInitStb(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STB, mndProcessMCreateStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_ALTER_STB, mndProcessMAlterStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessMDropStbReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_STB, mndProcessMDropStbReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndProcessVCreateStbRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_CREATE_STB_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndProcessVAlterStbRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndProcessVDropStbRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_TABLE_META, mndProcessTableMetaReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_TABLE_META, mndProcessTableMetaReq);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STB, mndRetrieveStb);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STB, mndRetrieveStb);
|
||||||
|
|
@ -837,11 +834,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVCreateStbRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
static int32_t mndCheckAlterStbReq(SMAlterStbReq *pAlter) {
|
||||||
if (pAlter->commentLen != 0 || pAlter->ttl != 0) return 0;
|
if (pAlter->commentLen != 0 || pAlter->ttl != 0) return 0;
|
||||||
|
|
||||||
|
|
@ -1459,11 +1451,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVAlterStbRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
static int32_t mndSetDropStbRedoLogs(SMnode *pMnode, STrans *pTrans, SStbObj *pStb) {
|
||||||
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
SSdbRaw *pRedoRaw = mndStbActionEncode(pStb);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
|
|
@ -1599,11 +1586,6 @@ _OVER:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessVDropStbRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
static int32_t mndProcessTableMetaReq(SRpcMsg *pReq) {
|
||||||
SMnode *pMnode = pReq->info.node;
|
SMnode *pMnode = pReq->info.node;
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
|
||||||
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream);
|
||||||
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream);
|
static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream);
|
||||||
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessTaskDeployInternalRsp(SRpcMsg *pRsp);
|
|
||||||
/*static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);*/
|
/*static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);*/
|
||||||
/*static int32_t mndProcessDropStreamInRsp(SRpcMsg *pRsp);*/
|
/*static int32_t mndProcessDropStreamInRsp(SRpcMsg *pRsp);*/
|
||||||
static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
|
static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq);
|
||||||
|
|
@ -44,17 +43,19 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
||||||
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextStream(SMnode *pMnode, void *pIter);
|
||||||
|
|
||||||
int32_t mndInitStream(SMnode *pMnode) {
|
int32_t mndInitStream(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_STREAM,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_STREAM,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
.encodeFp = (SdbEncodeFp)mndStreamActionEncode,
|
.encodeFp = (SdbEncodeFp)mndStreamActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndStreamActionDecode,
|
.decodeFp = (SdbDecodeFp)mndStreamActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndStreamActionInsert,
|
.insertFp = (SdbInsertFp)mndStreamActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndStreamActionUpdate,
|
.updateFp = (SdbUpdateFp)mndStreamActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndStreamActionDelete};
|
.deleteFp = (SdbDeleteFp)mndStreamActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_TASK_DEPLOY_RSP, mndProcessTaskDeployInternalRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_SND_TASK_DEPLOY_RSP, mndProcessTaskDeployInternalRsp);
|
mndSetMsgHandle(pMnode, TDMT_SND_TASK_DEPLOY_RSP, mndTransProcessRsp);
|
||||||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
|
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
|
||||||
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
|
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
|
||||||
|
|
||||||
|
|
@ -195,11 +196,6 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
|
||||||
sdbRelease(pSdb, pStream);
|
sdbRelease(pSdb, pStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessTaskDeployInternalRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SDbObj *mndAcquireDbByStream(SMnode *pMnode, char *streamName) {
|
static SDbObj *mndAcquireDbByStream(SMnode *pMnode, char *streamName) {
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
tNameFromString(&name, streamName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
tNameFromString(&name, streamName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubs
|
||||||
|
|
||||||
static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg);
|
static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg);
|
static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg);
|
||||||
static int32_t mndProcessSubscribeInternalRsp(SRpcMsg *pMsg);
|
|
||||||
|
|
||||||
static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextSubscribe(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextSubscribe(SMnode *pMnode, void *pIter);
|
||||||
|
|
@ -65,20 +64,22 @@ static int32_t mndSetSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeO
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndInitSubscribe(SMnode *pMnode) {
|
int32_t mndInitSubscribe(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_SUBSCRIBE,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_SUBSCRIBE,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
.encodeFp = (SdbEncodeFp)mndSubActionEncode,
|
.encodeFp = (SdbEncodeFp)mndSubActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndSubActionDecode,
|
.decodeFp = (SdbDecodeFp)mndSubActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndSubActionInsert,
|
.insertFp = (SdbInsertFp)mndSubActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndSubActionUpdate,
|
.updateFp = (SdbUpdateFp)mndSubActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndSubActionDelete};
|
.deleteFp = (SdbDeleteFp)mndSubActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_CHANGE_RSP, mndProcessSubscribeInternalRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_CHANGE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_DELETE_RSP, mndProcessSubscribeInternalRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_MQ_VG_DELETE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DO_REBALANCE, mndProcessRebalanceReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP, mndProcessDropCgroupReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP, mndProcessDropCgroupReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP_RSP, mndProcessSubscribeInternalRsp);
|
mndSetMsgHandle(pMnode, TDMT_MND_MQ_DROP_CGROUP_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_SUBSCRIPTIONS, mndRetrieveSubscribe);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_SUBSCRIPTIONS, mndRetrieveSubscribe);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextSubscribe);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextSubscribe);
|
||||||
|
|
@ -789,11 +790,6 @@ void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub) {
|
||||||
sdbRelease(pSdb, pSub);
|
sdbRelease(pSdb, pSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessSubscribeInternalRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndSetDropSubRedoLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) {
|
static int32_t mndSetDropSubRedoLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) {
|
||||||
SSdbRaw *pRedoRaw = mndSubActionEncode(pSub);
|
SSdbRaw *pRedoRaw = mndSubActionEncode(pSub);
|
||||||
if (pRedoRaw == NULL) return -1;
|
if (pRedoRaw == NULL) return -1;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic);
|
||||||
static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj *pNewTopic);
|
static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pTopic, SMqTopicObj *pNewTopic);
|
||||||
static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq);
|
static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropTopicReq(SRpcMsg *pReq);
|
static int32_t mndProcessDropTopicReq(SRpcMsg *pReq);
|
||||||
static int32_t mndProcessDropTopicInRsp(SRpcMsg *pRsp);
|
|
||||||
|
|
||||||
static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveTopic(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
||||||
|
|
@ -45,17 +44,19 @@ static void mndCancelGetNextTopic(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndSetDropTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
static int32_t mndSetDropTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic);
|
||||||
|
|
||||||
int32_t mndInitTopic(SMnode *pMnode) {
|
int32_t mndInitTopic(SMnode *pMnode) {
|
||||||
SSdbTable table = {.sdbType = SDB_TOPIC,
|
SSdbTable table = {
|
||||||
|
.sdbType = SDB_TOPIC,
|
||||||
.keyType = SDB_KEY_BINARY,
|
.keyType = SDB_KEY_BINARY,
|
||||||
.encodeFp = (SdbEncodeFp)mndTopicActionEncode,
|
.encodeFp = (SdbEncodeFp)mndTopicActionEncode,
|
||||||
.decodeFp = (SdbDecodeFp)mndTopicActionDecode,
|
.decodeFp = (SdbDecodeFp)mndTopicActionDecode,
|
||||||
.insertFp = (SdbInsertFp)mndTopicActionInsert,
|
.insertFp = (SdbInsertFp)mndTopicActionInsert,
|
||||||
.updateFp = (SdbUpdateFp)mndTopicActionUpdate,
|
.updateFp = (SdbUpdateFp)mndTopicActionUpdate,
|
||||||
.deleteFp = (SdbDeleteFp)mndTopicActionDelete};
|
.deleteFp = (SdbDeleteFp)mndTopicActionDelete,
|
||||||
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TOPIC, mndProcessCreateTopicReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TOPIC, mndProcessCreateTopicReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
mndSetMsgHandle(pMnode, TDMT_MND_DROP_TOPIC, mndProcessDropTopicReq);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndProcessDropTopicInRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_DROP_TOPIC_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndCancelGetNextTopic);
|
||||||
|
|
@ -607,11 +608,6 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessDropTopicInRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) {
|
static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) {
|
||||||
SSdb *pSdb = pMnode->pSdb;
|
SSdb *pSdb = pMnode->pSdb;
|
||||||
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
SDbObj *pDb = mndAcquireDb(pMnode, dbName);
|
||||||
|
|
|
||||||
|
|
@ -88,12 +88,14 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < actionNum; ++i) {
|
for (int32_t i = 0; i < actionNum; ++i) {
|
||||||
STransAction *pAction = taosArrayGet(pArray, i);
|
STransAction *pAction = taosArrayGet(pArray, i);
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
rawDataLen += (sdbGetRawTotalSize(pAction->pRaw) + sizeof(int32_t));
|
rawDataLen += (sdbGetRawTotalSize(pAction->pRaw) + sizeof(int32_t));
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
rawDataLen += (sizeof(STransAction) + pAction->contLen);
|
||||||
|
} else {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
rawDataLen += sizeof(pAction->actionType);
|
rawDataLen += sizeof(int8_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawDataLen;
|
return rawDataLen;
|
||||||
|
|
@ -137,18 +139,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||||
|
} else {
|
||||||
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,18 +163,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||||
|
} else {
|
||||||
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,18 +187,20 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->acceptableCode, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->actionType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->stage, _OVER)
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
int32_t len = sdbGetRawTotalSize(pAction->pRaw);
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->rawWritten, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, len, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)pAction->pRaw, len, _OVER)
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, (void *)&pAction->epSet, sizeof(SEpSet), _OVER)
|
||||||
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
SDB_SET_INT16(pRaw, dataPos, pAction->msgType, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgSent, _OVER)
|
||||||
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
SDB_SET_INT8(pRaw, dataPos, pAction->msgReceived, _OVER)
|
||||||
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
SDB_SET_INT32(pRaw, dataPos, pAction->contLen, _OVER)
|
||||||
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
SDB_SET_BINARY(pRaw, dataPos, pAction->pCont, pAction->contLen, _OVER)
|
||||||
|
} else {
|
||||||
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,6 +260,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
int16_t policy = 0;
|
int16_t policy = 0;
|
||||||
int16_t conflict = 0;
|
int16_t conflict = 0;
|
||||||
int16_t exec = 0;
|
int16_t exec = 0;
|
||||||
|
int8_t actionType = 0;
|
||||||
SDB_GET_INT16(pRaw, dataPos, &stage, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &stage, _OVER)
|
||||||
SDB_GET_INT16(pRaw, dataPos, &policy, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &policy, _OVER)
|
||||||
SDB_GET_INT16(pRaw, dataPos, &conflict, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &conflict, _OVER)
|
||||||
|
|
@ -279,9 +288,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||||
|
action.actionType = actionType;
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||||
if (action.actionType) {
|
if (action.actionType == TRANS_ACTION_RAW) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
action.pRaw = taosMemoryMalloc(dataLen);
|
action.pRaw = taosMemoryMalloc(dataLen);
|
||||||
|
|
@ -290,7 +300,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
action.pRaw = NULL;
|
action.pRaw = NULL;
|
||||||
} else {
|
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||||
|
|
@ -301,6 +311,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
action.pCont = NULL;
|
action.pCont = NULL;
|
||||||
|
} else {
|
||||||
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,9 +320,10 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||||
|
action.actionType = actionType;
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||||
if (action.actionType) {
|
if (action.actionType == TRANS_ACTION_RAW) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &dataLen, _OVER)
|
||||||
action.pRaw = taosMemoryMalloc(dataLen);
|
action.pRaw = taosMemoryMalloc(dataLen);
|
||||||
|
|
@ -319,7 +332,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
||||||
action.pRaw = NULL;
|
action.pRaw = NULL;
|
||||||
} else {
|
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||||
|
|
@ -330,6 +343,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->undoActions, &action) == NULL) goto _OVER;
|
||||||
action.pCont = NULL;
|
action.pCont = NULL;
|
||||||
|
} else {
|
||||||
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,7 +352,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.id, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.errCode, _OVER)
|
||||||
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
SDB_GET_INT32(pRaw, dataPos, &action.acceptableCode, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.actionType, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &actionType, _OVER)
|
||||||
|
action.actionType = actionType;
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.stage, _OVER)
|
||||||
if (action.actionType) {
|
if (action.actionType) {
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.rawWritten, _OVER)
|
||||||
|
|
@ -348,7 +364,7 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)action.pRaw, dataLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
||||||
action.pRaw = NULL;
|
action.pRaw = NULL;
|
||||||
} else {
|
} else if (action.actionType == TRANS_ACTION_MSG) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, (void *)&action.epSet, sizeof(SEpSet), _OVER);
|
||||||
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
SDB_GET_INT16(pRaw, dataPos, &action.msgType, _OVER)
|
||||||
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
SDB_GET_INT8(pRaw, dataPos, &action.msgSent, _OVER)
|
||||||
|
|
@ -359,6 +375,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
|
||||||
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
SDB_GET_BINARY(pRaw, dataPos, action.pCont, action.contLen, _OVER);
|
||||||
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
if (taosArrayPush(pTrans->commitActions, &action) == NULL) goto _OVER;
|
||||||
action.pCont = NULL;
|
action.pCont = NULL;
|
||||||
|
} else {
|
||||||
|
if (taosArrayPush(pTrans->redoActions, &action) == NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -552,10 +570,12 @@ static void mndTransDropActions(SArray *pArray) {
|
||||||
int32_t size = taosArrayGetSize(pArray);
|
int32_t size = taosArrayGetSize(pArray);
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
STransAction *pAction = taosArrayGet(pArray, i);
|
STransAction *pAction = taosArrayGet(pArray, i);
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
taosMemoryFreeClear(pAction->pRaw);
|
taosMemoryFreeClear(pAction->pRaw);
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
taosMemoryFreeClear(pAction->pCont);
|
taosMemoryFreeClear(pAction->pCont);
|
||||||
|
} else {
|
||||||
|
// nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -583,27 +603,34 @@ static int32_t mndTransAppendAction(SArray *pArray, STransAction *pAction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = true, .pRaw = pRaw};
|
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||||
|
return mndTransAppendAction(pTrans->redoActions, &action);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t mndTransAppendNullLog(STrans *pTrans) {
|
||||||
|
STransAction action = {.stage = TRN_STAGE_REDO_ACTION, .actionType = TRANS_ACTION_NULL};
|
||||||
return mndTransAppendAction(pTrans->redoActions, &action);
|
return mndTransAppendAction(pTrans->redoActions, &action);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendUndolog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
STransAction action = {.stage = TRN_STAGE_UNDO_ACTION, .actionType = true, .pRaw = pRaw};
|
STransAction action = {.stage = TRN_STAGE_UNDO_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||||
return mndTransAppendAction(pTrans->undoActions, &action);
|
return mndTransAppendAction(pTrans->undoActions, &action);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
|
int32_t mndTransAppendCommitlog(STrans *pTrans, SSdbRaw *pRaw) {
|
||||||
STransAction action = {.stage = TRN_STAGE_COMMIT_ACTION, .actionType = true, .pRaw = pRaw};
|
STransAction action = {.stage = TRN_STAGE_COMMIT_ACTION, .actionType = TRANS_ACTION_RAW, .pRaw = pRaw};
|
||||||
return mndTransAppendAction(pTrans->commitActions, &action);
|
return mndTransAppendAction(pTrans->commitActions, &action);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction) {
|
int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction) {
|
||||||
pAction->stage = TRN_STAGE_REDO_ACTION;
|
pAction->stage = TRN_STAGE_REDO_ACTION;
|
||||||
|
pAction->actionType = TRANS_ACTION_MSG;
|
||||||
return mndTransAppendAction(pTrans->redoActions, pAction);
|
return mndTransAppendAction(pTrans->redoActions, pAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction) {
|
int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction) {
|
||||||
pAction->stage = TRN_STAGE_UNDO_ACTION;
|
pAction->stage = TRN_STAGE_UNDO_ACTION;
|
||||||
|
pAction->actionType = TRANS_ACTION_MSG;
|
||||||
return mndTransAppendAction(pTrans->undoActions, pAction);
|
return mndTransAppendAction(pTrans->undoActions, pAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -782,7 +809,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mndTransProcessRsp(SRpcMsg *pRsp) {
|
int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||||
SMnode *pMnode = pRsp->info.node;
|
SMnode *pMnode = pRsp->info.node;
|
||||||
int64_t signature = (int64_t)(pRsp->info.ahandle);
|
int64_t signature = (int64_t)(pRsp->info.ahandle);
|
||||||
int32_t transId = (int32_t)(signature >> 32);
|
int32_t transId = (int32_t)(signature >> 32);
|
||||||
|
|
@ -827,6 +854,7 @@ void mndTransProcessRsp(SRpcMsg *pRsp) {
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
mndReleaseTrans(pMnode, pTrans);
|
mndReleaseTrans(pMnode, pTrans);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray) {
|
||||||
|
|
@ -842,9 +870,16 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray)
|
||||||
pAction->rawWritten = 0;
|
pAction->rawWritten = 0;
|
||||||
pAction->msgSent = 0;
|
pAction->msgSent = 0;
|
||||||
pAction->msgReceived = 0;
|
pAction->msgReceived = 0;
|
||||||
pAction->errCode = 0;
|
if (pAction->errCode == TSDB_CODE_RPC_REDIRECT) {
|
||||||
|
pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps;
|
||||||
|
mDebug("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage),
|
||||||
|
action, pAction->epSet.inUse);
|
||||||
|
} else {
|
||||||
mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action);
|
mDebug("trans:%d, %s:%d execute status is reset", pTrans->id, mndTransStr(pAction->stage), action);
|
||||||
}
|
}
|
||||||
|
pAction->errCode = 0;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
||||||
|
|
@ -899,10 +934,15 @@ static int32_t mndTransSendSingleMsg(SMnode *pMnode, STrans *pTrans, STransActio
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndTransExecSingleAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
static int32_t mndTransExecSingleAction(SMnode *pMnode, STrans *pTrans, STransAction *pAction) {
|
||||||
if (pAction->actionType) {
|
if (pAction->actionType == TRANS_ACTION_RAW) {
|
||||||
return mndTransWriteSingleLog(pMnode, pTrans, pAction);
|
return mndTransWriteSingleLog(pMnode, pTrans, pAction);
|
||||||
} else {
|
} else if (pAction->actionType == TRANS_ACTION_MSG) {
|
||||||
return mndTransSendSingleMsg(pMnode, pTrans, pAction);
|
return mndTransSendSingleMsg(pMnode, pTrans, pAction);
|
||||||
|
} else {
|
||||||
|
pAction->rawWritten = 0;
|
||||||
|
pAction->errCode = 0;
|
||||||
|
mDebug("trans:%d, %s:%d null action executed", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,6 @@ static int32_t mndVgroupActionInsert(SSdb *pSdb, SVgObj *pVgroup);
|
||||||
static int32_t mndVgroupActionDelete(SSdb *pSdb, SVgObj *pVgroup);
|
static int32_t mndVgroupActionDelete(SSdb *pSdb, SVgObj *pVgroup);
|
||||||
static int32_t mndVgroupActionUpdate(SSdb *pSdb, SVgObj *pOld, SVgObj *pNew);
|
static int32_t mndVgroupActionUpdate(SSdb *pSdb, SVgObj *pOld, SVgObj *pNew);
|
||||||
|
|
||||||
static int32_t mndProcessCreateVnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessAlterVnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessDropVnodeRsp(SRpcMsg *pRsp);
|
|
||||||
static int32_t mndProcessCompactVnodeRsp(SRpcMsg *pRsp);
|
|
||||||
|
|
||||||
static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter);
|
static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter);
|
||||||
static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
||||||
|
|
@ -50,11 +45,12 @@ int32_t mndInitVgroup(SMnode *pMnode) {
|
||||||
.deleteFp = (SdbDeleteFp)mndVgroupActionDelete,
|
.deleteFp = (SdbDeleteFp)mndVgroupActionDelete,
|
||||||
};
|
};
|
||||||
|
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_VNODE_RSP, mndProcessCreateVnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_CREATE_VNODE_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_REPLICA_RSP, mndProcessAlterVnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_REPLICA_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_CONFIG_RSP, mndProcessAlterVnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_CONFIG_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_DND_DROP_VNODE_RSP, mndProcessDropVnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_VND_ALTER_CONFIRM_RSP, mndTransProcessRsp);
|
||||||
mndSetMsgHandle(pMnode, TDMT_VND_COMPACT_RSP, mndProcessCompactVnodeRsp);
|
mndSetMsgHandle(pMnode, TDMT_DND_DROP_VNODE_RSP, mndTransProcessRsp);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_VND_COMPACT_RSP, mndTransProcessRsp);
|
||||||
|
|
||||||
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndRetrieveVgroups);
|
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndRetrieveVgroups);
|
||||||
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndCancelGetNextVgroup);
|
mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndCancelGetNextVgroup);
|
||||||
|
|
@ -512,12 +508,12 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
|
||||||
mDebug("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
mDebug("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t maxPos = 1;
|
SVnodeGid *pVgid = &pVgroup->vnodeGid[pVgroup->replica];
|
||||||
for (int32_t d = 0; d < taosArrayGetSize(pArray); ++d) {
|
for (int32_t d = 0; d < taosArrayGetSize(pArray); ++d) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, d);
|
SDnodeObj *pDnode = taosArrayGet(pArray, d);
|
||||||
|
|
||||||
bool used = false;
|
bool used = false;
|
||||||
for (int32_t vn = 0; vn < maxPos; ++vn) {
|
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||||
if (pDnode->id == pVgroup->vnodeGid[vn].dnodeId) {
|
if (pDnode->id == pVgroup->vnodeGid[vn].dnodeId) {
|
||||||
used = true;
|
used = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -530,59 +526,58 @@ int32_t mndAddVnodeToVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[maxPos];
|
|
||||||
pVgid->dnodeId = pDnode->id;
|
pVgid->dnodeId = pDnode->id;
|
||||||
pVgid->role = TAOS_SYNC_STATE_ERROR;
|
pVgid->role = TAOS_SYNC_STATE_ERROR;
|
||||||
pDnode->numOfVnodes++;
|
mInfo("db:%s, vgId:%d, vn:%d dnode:%d, is added", pVgroup->dbName, pVgroup->vgId, pVgroup->replica,
|
||||||
|
pVgid->dnodeId);
|
||||||
|
|
||||||
mInfo("db:%s, vgId:%d, vnode_index:%d dnode:%d is added", pVgroup->dbName, pVgroup->vgId, maxPos, pVgid->dnodeId);
|
pVgroup->replica++;
|
||||||
maxPos++;
|
pDnode->numOfVnodes++;
|
||||||
if (maxPos == 3) return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
|
||||||
|
mError("db:%s, failed to add vnode to vgId:%d since %s", pVgroup->dbName, pVgroup->vgId, terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray, SVnodeGid *del1, SVnodeGid *del2) {
|
int32_t mndRemoveVnodeFromVgroup(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray, SVnodeGid *pDelVgid) {
|
||||||
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
SDnodeObj *pDnode = taosArrayGet(pArray, i);
|
||||||
mDebug("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
mDebug("dnode:%d, equivalent vnodes:%d", pDnode->id, pDnode->numOfVnodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t removedNum = 0;
|
int32_t code = -1;
|
||||||
for (int32_t d = taosArrayGetSize(pArray) - 1; d >= 0; --d) {
|
for (int32_t d = taosArrayGetSize(pArray) - 1; d >= 0; --d) {
|
||||||
SDnodeObj *pDnode = taosArrayGet(pArray, d);
|
SDnodeObj *pDnode = taosArrayGet(pArray, d);
|
||||||
|
|
||||||
for (int32_t vn = 0; vn < TSDB_MAX_REPLICA; ++vn) {
|
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[vn];
|
SVnodeGid *pVgid = &pVgroup->vnodeGid[vn];
|
||||||
if (pVgid->dnodeId == pDnode->id) {
|
if (pVgid->dnodeId == pDnode->id) {
|
||||||
if (removedNum == 0) *del1 = *pVgid;
|
mInfo("db:%s, vgId:%d, vn:%d dnode:%d, is removed", pVgroup->dbName, pVgroup->vgId, vn, pVgid->dnodeId);
|
||||||
if (removedNum == 1) *del2 = *pVgid;
|
|
||||||
|
|
||||||
mInfo("db:%s, vgId:%d, vn:%d dnode:%d is removed", pVgroup->dbName, pVgroup->vgId, vn, pVgid->dnodeId);
|
|
||||||
memset(pVgid, 0, sizeof(SVnodeGid));
|
|
||||||
removedNum++;
|
|
||||||
pDnode->numOfVnodes--;
|
pDnode->numOfVnodes--;
|
||||||
|
pVgroup->replica--;
|
||||||
if (removedNum == 2) goto _OVER;
|
*pDelVgid = *pVgid;
|
||||||
|
*pVgid = pVgroup->vnodeGid[pVgroup->replica];
|
||||||
|
memset(&pVgroup->vnodeGid[pVgroup->replica], 0, sizeof(SVnodeGid));
|
||||||
|
code = 0;
|
||||||
|
goto _OVER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_OVER:
|
_OVER:
|
||||||
if (removedNum != 2) return -1;
|
if (code != 0) {
|
||||||
|
terrno = TSDB_CODE_APP_ERROR;
|
||||||
|
mError("db:%s, failed to remove vnode from vgId:%d since %s", pVgroup->dbName, pVgroup->vgId, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t vn = 1; vn < TSDB_MAX_REPLICA; ++vn) {
|
for (int32_t vn = 0; vn < pVgroup->replica; ++vn) {
|
||||||
SVnodeGid *pVgid = &pVgroup->vnodeGid[vn];
|
SVnodeGid *pVgid = &pVgroup->vnodeGid[vn];
|
||||||
if (pVgid->dnodeId != 0) {
|
mInfo("db:%s, vgId:%d, vn:%d dnode:%d is reserved", pVgroup->dbName, pVgroup->vgId, vn, pVgid->dnodeId);
|
||||||
memcpy(&pVgroup->vnodeGid[0], pVgid, sizeof(SVnodeGid));
|
|
||||||
memset(pVgid, 0, sizeof(SVnodeGid));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mInfo("db:%s, vgId:%d, dnode:%d is keeped", pVgroup->dbName, pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -605,23 +600,6 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) {
|
||||||
return epset;
|
return epset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mndProcessCreateVnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessAlterVnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessDropVnodeRsp(SRpcMsg *pRsp) {
|
|
||||||
mndTransProcessRsp(pRsp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndProcessCompactVnodeRsp(SRpcMsg *pRsp) { return 0; }
|
|
||||||
|
|
||||||
static bool mndGetVgroupMaxReplicaFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
static bool mndGetVgroupMaxReplicaFp(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
|
||||||
SVgObj *pVgroup = pObj;
|
SVgObj *pVgroup = pObj;
|
||||||
int64_t uid = *(int64_t *)p1;
|
int64_t uid = *(int64_t *)p1;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ target_sources(
|
||||||
|
|
||||||
# tsdb
|
# tsdb
|
||||||
"src/tsdb/tsdbCommit.c"
|
"src/tsdb/tsdbCommit.c"
|
||||||
|
"src/tsdb/tsdbCommit2.c"
|
||||||
"src/tsdb/tsdbFile.c"
|
"src/tsdb/tsdbFile.c"
|
||||||
"src/tsdb/tsdbFS.c"
|
"src/tsdb/tsdbFS.c"
|
||||||
"src/tsdb/tsdbOpen.c"
|
"src/tsdb/tsdbOpen.c"
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ bool isTsdbCacheLastRow(tsdbReaderT *pReader);
|
||||||
int32_t tsdbGetAllTableList(SMeta *pMeta, uint64_t uid, SArray *list);
|
int32_t tsdbGetAllTableList(SMeta *pMeta, uint64_t uid, SArray *list);
|
||||||
int32_t tsdbGetCtbIdList(SMeta *pMeta, int64_t suid, SArray *list);
|
int32_t tsdbGetCtbIdList(SMeta *pMeta, int64_t suid, SArray *list);
|
||||||
void * tsdbGetIdx(SMeta *pMeta);
|
void * tsdbGetIdx(SMeta *pMeta);
|
||||||
|
void * tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT *pHandle);
|
||||||
|
|
||||||
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,11 @@ struct SMeta {
|
||||||
TTB* pUidIdx;
|
TTB* pUidIdx;
|
||||||
TTB* pNameIdx;
|
TTB* pNameIdx;
|
||||||
TTB* pCtbIdx;
|
TTB* pCtbIdx;
|
||||||
#ifdef USE_INVERTED_INDEX
|
// ivt idx and idx
|
||||||
void* pTagIvtIdx;
|
void* pTagIvtIdx;
|
||||||
#else
|
|
||||||
TTB* pTagIdx;
|
TTB* pTagIdx;
|
||||||
#endif
|
|
||||||
TTB* pTtlIdx;
|
TTB* pTtlIdx;
|
||||||
|
|
||||||
TTB* pSmaIdx;
|
TTB* pSmaIdx;
|
||||||
SMetaIdx* pIdx;
|
SMetaIdx* pIdx;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -34,18 +34,97 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct TSDBROW TSDBROW;
|
typedef struct TSDBROW TSDBROW;
|
||||||
typedef struct TSDBKEY TSDBKEY;
|
typedef struct TSDBKEY TSDBKEY;
|
||||||
|
typedef struct TABLEID TABLEID;
|
||||||
typedef struct SDelOp SDelOp;
|
typedef struct SDelOp SDelOp;
|
||||||
|
|
||||||
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
||||||
|
|
||||||
// tsdbMemTable2.c ==============================================================================================
|
// tsdbMemTable2.c ==============================================================================================
|
||||||
typedef struct SMemTable SMemTable;
|
typedef struct SMemTable SMemTable;
|
||||||
|
typedef struct SMemData SMemData;
|
||||||
|
typedef struct SMemDataIter SMemDataIter;
|
||||||
|
|
||||||
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable);
|
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||||
void tsdbMemTableDestroy2(SMemTable *pMemTable);
|
void tsdbMemTableDestroy2(SMemTable *pMemTable);
|
||||||
|
int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmitBlk);
|
||||||
|
int32_t tsdbDeleteTableData2(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||||
|
|
||||||
|
/* SMemDataIter */
|
||||||
|
void tsdbMemDataIterOpen(SMemData *pMemData, TSDBKEY *pKey, int8_t backward, SMemDataIter *pIter);
|
||||||
|
bool tsdbMemDataIterNext(SMemDataIter *pIter);
|
||||||
|
void tsdbMemDataIterGet(SMemDataIter *pIter, TSDBROW **ppRow);
|
||||||
|
|
||||||
|
// tsdbCommit2.c ==============================================================================================
|
||||||
|
int32_t tsdbBegin2(STsdb *pTsdb);
|
||||||
|
int32_t tsdbCommit2(STsdb *pTsdb);
|
||||||
|
|
||||||
|
// tsdbFile.c ==============================================================================================
|
||||||
|
typedef int32_t TSDB_FILE_T;
|
||||||
|
typedef struct SDFInfo SDFInfo;
|
||||||
|
typedef struct SDFile SDFile;
|
||||||
|
typedef struct SDFileSet SDFileSet;
|
||||||
|
|
||||||
|
// SDFile
|
||||||
|
void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t ver, TSDB_FILE_T ftype);
|
||||||
|
void tsdbInitDFileEx(SDFile *pDFile, SDFile *pODFile);
|
||||||
|
int tsdbOpenDFile(SDFile *pDFile, int flags);
|
||||||
|
void tsdbCloseDFile(SDFile *pDFile);
|
||||||
|
int64_t tsdbSeekDFile(SDFile *pDFile, int64_t offset, int whence);
|
||||||
|
int64_t tsdbWriteDFile(SDFile *pDFile, void *buf, int64_t nbyte);
|
||||||
|
void tsdbUpdateDFileMagic(SDFile *pDFile, void *pCksm);
|
||||||
|
int tsdbAppendDFile(SDFile *pDFile, void *buf, int64_t nbyte, int64_t *offset);
|
||||||
|
int tsdbRemoveDFile(SDFile *pDFile);
|
||||||
|
int64_t tsdbReadDFile(SDFile *pDFile, void *buf, int64_t nbyte);
|
||||||
|
int tsdbCopyDFile(SDFile *pSrc, SDFile *pDest);
|
||||||
|
int tsdbEncodeSDFile(void **buf, SDFile *pDFile);
|
||||||
|
void *tsdbDecodeSDFile(STsdb *pRepo, void *buf, SDFile *pDFile);
|
||||||
|
int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T fType);
|
||||||
|
int tsdbUpdateDFileHeader(SDFile *pDFile);
|
||||||
|
int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo);
|
||||||
|
int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype, uint32_t *version);
|
||||||
|
|
||||||
|
// SDFileSet
|
||||||
|
void tsdbInitDFileSet(STsdb *pRepo, SDFileSet *pSet, SDiskID did, int fid, uint32_t ver);
|
||||||
|
void tsdbInitDFileSetEx(SDFileSet *pSet, SDFileSet *pOSet);
|
||||||
|
int tsdbEncodeDFileSet(void **buf, SDFileSet *pSet);
|
||||||
|
void *tsdbDecodeDFileSet(STsdb *pRepo, void *buf, SDFileSet *pSet);
|
||||||
|
int tsdbEncodeDFileSetEx(void **buf, SDFileSet *pSet);
|
||||||
|
void *tsdbDecodeDFileSetEx(void *buf, SDFileSet *pSet);
|
||||||
|
int tsdbApplyDFileSetChange(SDFileSet *from, SDFileSet *to);
|
||||||
|
int tsdbCreateDFileSet(STsdb *pRepo, SDFileSet *pSet, bool updateHeader);
|
||||||
|
int tsdbUpdateDFileSetHeader(SDFileSet *pSet);
|
||||||
|
int tsdbScanAndTryFixDFileSet(STsdb *pRepo, SDFileSet *pSet);
|
||||||
|
void tsdbCloseDFileSet(SDFileSet *pSet);
|
||||||
|
int tsdbOpenDFileSet(SDFileSet *pSet, int flags);
|
||||||
|
void tsdbRemoveDFileSet(SDFileSet *pSet);
|
||||||
|
int tsdbCopyDFileSet(SDFileSet *pSrc, SDFileSet *pDest);
|
||||||
|
void tsdbGetFidKeyRange(int days, int8_t precision, int fid, TSKEY *minKey, TSKEY *maxKey);
|
||||||
|
|
||||||
|
// tsdbFS.c ==============================================================================================
|
||||||
|
typedef struct STsdbFS STsdbFS;
|
||||||
|
typedef struct SFSIter SFSIter;
|
||||||
|
typedef struct STsdbFSMeta STsdbFSMeta;
|
||||||
|
|
||||||
|
STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg);
|
||||||
|
void *tsdbFreeFS(STsdbFS *pfs);
|
||||||
|
int tsdbOpenFS(STsdb *pRepo);
|
||||||
|
void tsdbCloseFS(STsdb *pRepo);
|
||||||
|
void tsdbStartFSTxn(STsdb *pRepo, int64_t pointsAdd, int64_t storageAdd);
|
||||||
|
int tsdbEndFSTxn(STsdb *pRepo);
|
||||||
|
int tsdbEndFSTxnWithError(STsdbFS *pfs);
|
||||||
|
void tsdbUpdateFSTxnMeta(STsdbFS *pfs, STsdbFSMeta *pMeta);
|
||||||
|
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
|
||||||
|
int tsdbUpdateDFileSet(STsdbFS *pfs, const SDFileSet *pSet);
|
||||||
|
|
||||||
|
void tsdbFSIterInit(SFSIter *pIter, STsdbFS *pfs, int direction);
|
||||||
|
void tsdbFSIterSeek(SFSIter *pIter, int fid);
|
||||||
|
SDFileSet *tsdbFSIterNext(SFSIter *pIter);
|
||||||
|
int tsdbLoadMetaCache(STsdb *pRepo, bool recoverMeta);
|
||||||
|
int tsdbRLockFS(STsdbFS *pFs);
|
||||||
|
int tsdbWLockFS(STsdbFS *pFs);
|
||||||
|
int tsdbUnLockFS(STsdbFS *pFs);
|
||||||
|
|
||||||
// tsdbMemTable ================
|
// tsdbMemTable ================
|
||||||
typedef struct STsdbRow STsdbRow;
|
|
||||||
typedef struct STbData STbData;
|
typedef struct STbData STbData;
|
||||||
typedef struct STsdbMemTable STsdbMemTable;
|
typedef struct STsdbMemTable STsdbMemTable;
|
||||||
typedef struct SMergeInfo SMergeInfo;
|
typedef struct SMergeInfo SMergeInfo;
|
||||||
|
|
@ -56,15 +135,6 @@ void tsdbMemTableDestroy(STsdbMemTable *pMemTable);
|
||||||
int tsdbLoadDataFromCache(STsdb *pTsdb, STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead,
|
int tsdbLoadDataFromCache(STsdb *pTsdb, STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead,
|
||||||
SDataCols *pCols, TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo);
|
SDataCols *pCols, TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo);
|
||||||
|
|
||||||
// tsdbCommit ================
|
|
||||||
|
|
||||||
// tsdbFS ================
|
|
||||||
typedef struct STsdbFS STsdbFS;
|
|
||||||
|
|
||||||
// tsdbSma ================
|
|
||||||
typedef struct SSmaEnv SSmaEnv;
|
|
||||||
typedef struct SSmaEnvs SSmaEnvs;
|
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int minFid;
|
int minFid;
|
||||||
|
|
@ -99,7 +169,7 @@ struct STable {
|
||||||
#define TABLE_TID(t) (t)->tid
|
#define TABLE_TID(t) (t)->tid
|
||||||
#define TABLE_UID(t) (t)->uid
|
#define TABLE_UID(t) (t)->uid
|
||||||
|
|
||||||
int tsdbPrepareCommit(STsdb *pTsdb);
|
// int tsdbPrepareCommit(STsdb *pTsdb);
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_FILE_HEAD = 0, // .head
|
TSDB_FILE_HEAD = 0, // .head
|
||||||
TSDB_FILE_DATA, // .data
|
TSDB_FILE_DATA, // .data
|
||||||
|
|
@ -110,7 +180,7 @@ typedef enum {
|
||||||
TSDB_FILE_META, // meta
|
TSDB_FILE_META, // meta
|
||||||
} E_TSDB_FILE_T;
|
} E_TSDB_FILE_T;
|
||||||
|
|
||||||
typedef struct {
|
struct SDFInfo {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
uint32_t fver;
|
uint32_t fver;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
@ -119,22 +189,22 @@ typedef struct {
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
uint64_t tombSize;
|
uint64_t tombSize;
|
||||||
} SDFInfo;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct SDFile {
|
||||||
SDFInfo info;
|
SDFInfo info;
|
||||||
STfsFile f;
|
STfsFile f;
|
||||||
TdFilePtr pFile;
|
TdFilePtr pFile;
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
} SDFile;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct SDFileSet {
|
||||||
int fid;
|
int fid;
|
||||||
int8_t state; // -128~127
|
int8_t state; // -128~127
|
||||||
uint8_t ver; // 0~255, DFileSet version
|
uint8_t ver; // 0~255, DFileSet version
|
||||||
uint16_t reserve;
|
uint16_t reserve;
|
||||||
SDFile files[TSDB_FILE_MAX];
|
SDFile files[TSDB_FILE_MAX];
|
||||||
} SDFileSet;
|
};
|
||||||
|
|
||||||
struct STbData {
|
struct STbData {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
|
|
@ -159,11 +229,11 @@ struct STsdbMemTable {
|
||||||
SHashObj *pHashIdx;
|
SHashObj *pHashIdx;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct STsdbFSMeta {
|
||||||
uint32_t version; // Commit version from 0 to increase
|
uint32_t version; // Commit version from 0 to increase
|
||||||
int64_t totalPoints; // total points
|
int64_t totalPoints; // total points
|
||||||
int64_t totalStorage; // Uncompressed total storage
|
int64_t totalStorage; // Uncompressed total storage
|
||||||
} STsdbFSMeta;
|
};
|
||||||
|
|
||||||
// ==================
|
// ==================
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -176,8 +246,6 @@ struct STsdbFS {
|
||||||
TdThreadRwlock lock;
|
TdThreadRwlock lock;
|
||||||
|
|
||||||
SFSStatus *cstatus; // current status
|
SFSStatus *cstatus; // current status
|
||||||
SHashObj *metaCache; // meta cache
|
|
||||||
SHashObj *metaCacheComp; // meta cache for compact
|
|
||||||
bool intxn;
|
bool intxn;
|
||||||
SFSStatus *nstatus; // new status
|
SFSStatus *nstatus; // new status
|
||||||
};
|
};
|
||||||
|
|
@ -243,31 +311,21 @@ static FORCE_INLINE TSKEY tsdbNextIterKey(SSkipListIterator *pIter) {
|
||||||
// tsdbReadImpl
|
// tsdbReadImpl
|
||||||
typedef struct SReadH SReadH;
|
typedef struct SReadH SReadH;
|
||||||
|
|
||||||
|
struct TSDBKEY {
|
||||||
|
int64_t version;
|
||||||
|
TSKEY ts;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
uint64_t suid;
|
||||||
|
uint64_t uid;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t hasLast : 2;
|
uint32_t hasLast : 2;
|
||||||
uint32_t numOfBlocks : 30;
|
uint32_t numOfBlocks : 30;
|
||||||
uint64_t uid;
|
TSDBKEY maxKey;
|
||||||
TSKEY maxKey;
|
|
||||||
} SBlockIdx;
|
} SBlockIdx;
|
||||||
|
|
||||||
#ifdef TD_REFACTOR_3
|
|
||||||
typedef struct {
|
|
||||||
int64_t last : 1;
|
|
||||||
int64_t offset : 63;
|
|
||||||
int32_t algorithm : 8;
|
|
||||||
int32_t numOfRows : 24;
|
|
||||||
int32_t len;
|
|
||||||
int32_t keyLen; // key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
|
|
||||||
int16_t numOfSubBlocks;
|
|
||||||
int16_t numOfCols; // not including timestamp column
|
|
||||||
TSKEY keyFirst;
|
|
||||||
TSKEY keyLast;
|
|
||||||
} SBlock;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SBLK_VER_0 = 0,
|
TSDB_SBLK_VER_0 = 0,
|
||||||
TSDB_SBLK_VER_MAX,
|
TSDB_SBLK_VER_MAX,
|
||||||
|
|
@ -290,16 +348,9 @@ typedef struct {
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
uint64_t aggrStat : 1;
|
uint64_t aggrStat : 1;
|
||||||
uint64_t aggrOffset : 63;
|
uint64_t aggrOffset : 63;
|
||||||
TSKEY keyFirst;
|
TSDBKEY minKey;
|
||||||
TSKEY keyLast;
|
TSDBKEY maxKey;
|
||||||
} SBlockV0;
|
} SBlock;
|
||||||
|
|
||||||
#define SBlock SBlockV0 // latest SBlock definition
|
|
||||||
|
|
||||||
static FORCE_INLINE bool tsdbIsSupBlock(SBlock *pBlock) { return pBlock->numOfSubBlocks == 1; }
|
|
||||||
static FORCE_INLINE bool tsdbIsSubBlock(SBlock *pBlock) { return pBlock->numOfSubBlocks == 0; }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t delimiter; // For recovery usage
|
int32_t delimiter; // For recovery usage
|
||||||
|
|
@ -308,33 +359,13 @@ typedef struct {
|
||||||
SBlock blocks[];
|
SBlock blocks[];
|
||||||
} SBlockInfo;
|
} SBlockInfo;
|
||||||
|
|
||||||
#ifdef TD_REFACTOR_3
|
|
||||||
typedef struct {
|
|
||||||
int16_t colId;
|
|
||||||
uint16_t bitmap : 1; // 0: no bitmap if all rows are NORM, 1: has bitmap if has NULL/NORM rows
|
|
||||||
uint16_t reserve : 15;
|
|
||||||
int32_t len;
|
|
||||||
uint32_t type : 8;
|
|
||||||
uint32_t offset : 24;
|
|
||||||
int64_t sum;
|
|
||||||
int64_t max;
|
|
||||||
int64_t min;
|
|
||||||
int16_t maxIndex;
|
|
||||||
int16_t minIndex;
|
|
||||||
int16_t numOfNull;
|
|
||||||
uint8_t offsetH;
|
|
||||||
char padding[1];
|
|
||||||
} SBlockCol;
|
|
||||||
#else
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
uint16_t type : 6;
|
uint16_t type : 6;
|
||||||
uint16_t blen : 10; // 0 no bitmap if all rows are NORM, > 0 bitmap length
|
uint16_t blen : 10; // 0 no bitmap if all rows are NORM, > 0 bitmap length
|
||||||
uint32_t len; // data length + bitmap length
|
uint32_t len; // data length + bitmap length
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
} SBlockColV0;
|
} SBlockCol;
|
||||||
|
|
||||||
#define SBlockCol SBlockColV0 // latest SBlockCol definition
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
|
|
@ -344,31 +375,7 @@ typedef struct {
|
||||||
int64_t sum;
|
int64_t sum;
|
||||||
int64_t max;
|
int64_t max;
|
||||||
int64_t min;
|
int64_t min;
|
||||||
} SAggrBlkColV0;
|
} SAggrBlkCol;
|
||||||
|
|
||||||
#define SAggrBlkCol SAggrBlkColV0 // latest SAggrBlkCol definition
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Code here just for back-ward compatibility
|
|
||||||
static FORCE_INLINE void tsdbSetBlockColOffset(SBlockCol *pBlockCol, uint32_t offset) {
|
|
||||||
#ifdef TD_REFACTOR_3
|
|
||||||
pBlockCol->offset = offset & ((((uint32_t)1) << 24) - 1);
|
|
||||||
pBlockCol->offsetH = (uint8_t)(offset >> 24);
|
|
||||||
#else
|
|
||||||
pBlockCol->offset = offset;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE uint32_t tsdbGetBlockColOffset(SBlockCol *pBlockCol) {
|
|
||||||
#ifdef TD_REFACTOR_3
|
|
||||||
uint32_t offset1 = pBlockCol->offset;
|
|
||||||
uint32_t offset2 = pBlockCol->offsetH;
|
|
||||||
return (offset1 | (offset2 << 24));
|
|
||||||
#else
|
|
||||||
return pBlockCol->offset;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t delimiter; // For recovery usage
|
int32_t delimiter; // For recovery usage
|
||||||
|
|
@ -409,8 +416,7 @@ struct SReadH {
|
||||||
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
|
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
|
||||||
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
|
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
|
||||||
|
|
||||||
#define TSDB_BLOCK_STATIS_SIZE(ncols, blkVer) \
|
#define TSDB_BLOCK_STATIS_SIZE(ncols, blkVer) (sizeof(SBlockData) + sizeof(SBlockCol) * (ncols) + sizeof(TSCKSUM))
|
||||||
(sizeof(SBlockData) + sizeof(SBlockColV##blkVer) * (ncols) + sizeof(TSCKSUM))
|
|
||||||
|
|
||||||
static FORCE_INLINE size_t tsdbBlockStatisSize(int nCols, uint32_t blkVer) {
|
static FORCE_INLINE size_t tsdbBlockStatisSize(int nCols, uint32_t blkVer) {
|
||||||
switch (blkVer) {
|
switch (blkVer) {
|
||||||
|
|
@ -420,7 +426,7 @@ static FORCE_INLINE size_t tsdbBlockStatisSize(int nCols, uint32_t blkVer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TSDB_BLOCK_AGGR_SIZE(ncols, blkVer) (sizeof(SAggrBlkColV##blkVer) * (ncols) + sizeof(TSCKSUM))
|
#define TSDB_BLOCK_AGGR_SIZE(ncols, blkVer) (sizeof(SAggrBlkCol) * (ncols) + sizeof(TSCKSUM))
|
||||||
|
|
||||||
static FORCE_INLINE size_t tsdbBlockAggrSize(int nCols, uint32_t blkVer) {
|
static FORCE_INLINE size_t tsdbBlockAggrSize(int nCols, uint32_t blkVer) {
|
||||||
switch (blkVer) {
|
switch (blkVer) {
|
||||||
|
|
@ -518,11 +524,11 @@ static FORCE_INLINE void *taosTZfree(void *ptr) {
|
||||||
|
|
||||||
void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn);
|
void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn);
|
||||||
|
|
||||||
static FORCE_INLINE int TSDB_KEY_FID(TSKEY key, int32_t days, int8_t precision) {
|
static FORCE_INLINE int TSDB_KEY_FID(TSKEY key, int32_t minutes, int8_t precision) {
|
||||||
if (key < 0) {
|
if (key < 0) {
|
||||||
return (int)((key + 1) / tsTickPerMin[precision] / days - 1);
|
return (int)((key + 1) / tsTickPerMin[precision] / minutes - 1);
|
||||||
} else {
|
} else {
|
||||||
return (int)((key / tsTickPerMin[precision] / days));
|
return (int)((key / tsTickPerMin[precision] / minutes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -546,7 +552,6 @@ static FORCE_INLINE int tsdbGetFidLevel(int fid, SRtn *pRtn) {
|
||||||
#define TSDB_FILE_STATE_OK 0
|
#define TSDB_FILE_STATE_OK 0
|
||||||
#define TSDB_FILE_STATE_BAD 1
|
#define TSDB_FILE_STATE_BAD 1
|
||||||
|
|
||||||
#define TSDB_FILE_INFO(tf) (&((tf)->info))
|
|
||||||
#define TSDB_FILE_F(tf) (&((tf)->f))
|
#define TSDB_FILE_F(tf) (&((tf)->f))
|
||||||
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
|
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
|
||||||
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
|
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
|
||||||
|
|
@ -564,7 +569,6 @@ static FORCE_INLINE int tsdbGetFidLevel(int fid, SRtn *pRtn) {
|
||||||
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
|
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
|
||||||
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
|
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
|
||||||
|
|
||||||
typedef int32_t TSDB_FILE_T;
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_FS_VER_0 = 0,
|
TSDB_FS_VER_0 = 0,
|
||||||
TSDB_FS_VER_MAX,
|
TSDB_FS_VER_MAX,
|
||||||
|
|
@ -585,129 +589,9 @@ static FORCE_INLINE uint32_t tsdbGetDFSVersion(TSDB_FILE_T fType) { // latest v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t ver, TSDB_FILE_T ftype);
|
|
||||||
void tsdbInitDFileEx(SDFile *pDFile, SDFile *pODFile);
|
|
||||||
int tsdbEncodeSDFile(void **buf, SDFile *pDFile);
|
|
||||||
void *tsdbDecodeSDFile(STsdb *pRepo, void *buf, SDFile *pDFile);
|
|
||||||
int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T fType);
|
|
||||||
int tsdbUpdateDFileHeader(SDFile *pDFile);
|
|
||||||
int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo);
|
|
||||||
int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype, uint32_t *version);
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbSetDFileInfo(SDFile *pDFile, SDFInfo *pInfo) { pDFile->info = *pInfo; }
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbOpenDFile(SDFile *pDFile, int flags) {
|
|
||||||
ASSERT(!TSDB_FILE_OPENED(pDFile));
|
|
||||||
|
|
||||||
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), flags);
|
|
||||||
if (pDFile->pFile == NULL) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbCloseDFile(SDFile *pDFile) {
|
|
||||||
if (TSDB_FILE_OPENED(pDFile)) {
|
|
||||||
taosCloseFile(&pDFile->pFile);
|
|
||||||
TSDB_FILE_SET_CLOSED(pDFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int64_t tsdbSeekDFile(SDFile *pDFile, int64_t offset, int whence) {
|
|
||||||
// ASSERT(TSDB_FILE_OPENED(pDFile));
|
|
||||||
|
|
||||||
int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
|
|
||||||
if (loffset < 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return loffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int64_t tsdbWriteDFile(SDFile *pDFile, void *buf, int64_t nbyte) {
|
|
||||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
|
||||||
|
|
||||||
int64_t nwrite = taosWriteFile(pDFile->pFile, buf, nbyte);
|
|
||||||
if (nwrite < nbyte) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nwrite;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbUpdateDFileMagic(SDFile *pDFile, void *pCksm) {
|
|
||||||
pDFile->info.magic = taosCalcChecksum(pDFile->info.magic, (uint8_t *)(pCksm), sizeof(TSCKSUM));
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbAppendDFile(SDFile *pDFile, void *buf, int64_t nbyte, int64_t *offset) {
|
|
||||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
|
||||||
|
|
||||||
int64_t toffset;
|
|
||||||
|
|
||||||
if ((toffset = tsdbSeekDFile(pDFile, 0, SEEK_END)) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(pDFile->info.size == toffset);
|
|
||||||
|
|
||||||
if (offset) {
|
|
||||||
*offset = toffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tsdbWriteDFile(pDFile, buf, nbyte) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDFile->info.size += nbyte;
|
|
||||||
|
|
||||||
return (int)nbyte;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbRemoveDFile(SDFile *pDFile) { return tfsRemoveFile(TSDB_FILE_F(pDFile)); }
|
|
||||||
|
|
||||||
static FORCE_INLINE int64_t tsdbReadDFile(SDFile *pDFile, void *buf, int64_t nbyte) {
|
|
||||||
ASSERT(TSDB_FILE_OPENED(pDFile));
|
|
||||||
|
|
||||||
int64_t nread = taosReadFile(pDFile->pFile, buf, nbyte);
|
|
||||||
if (nread < 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nread;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbCopyDFile(SDFile *pSrc, SDFile *pDest) {
|
|
||||||
if (tfsCopyFile(TSDB_FILE_F(pSrc), TSDB_FILE_F(pDest)) < 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbSetDFileInfo(pDest, TSDB_FILE_INFO(pSrc));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============== SDFileSet
|
// =============== SDFileSet
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int fid;
|
|
||||||
int8_t state;
|
|
||||||
uint8_t ver;
|
|
||||||
uint16_t reserve;
|
|
||||||
#if 0
|
|
||||||
SDFInfo info;
|
|
||||||
#endif
|
|
||||||
STfsFile f;
|
|
||||||
TdFilePtr pFile;
|
|
||||||
|
|
||||||
} SSFile; // files split by days with fid
|
|
||||||
|
|
||||||
#define TSDB_LATEST_FSET_VER 0
|
#define TSDB_LATEST_FSET_VER 0
|
||||||
|
|
||||||
#define TSDB_FSET_FID(s) ((s)->fid)
|
#define TSDB_FSET_FID(s) ((s)->fid)
|
||||||
#define TSDB_FSET_STATE(s) ((s)->state)
|
#define TSDB_FSET_STATE(s) ((s)->state)
|
||||||
#define TSDB_FSET_VER(s) ((s)->ver)
|
#define TSDB_FSET_VER(s) ((s)->ver)
|
||||||
|
|
@ -727,55 +611,6 @@ typedef struct {
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
void tsdbInitDFileSet(STsdb *pRepo, SDFileSet *pSet, SDiskID did, int fid, uint32_t ver);
|
|
||||||
void tsdbInitDFileSetEx(SDFileSet *pSet, SDFileSet *pOSet);
|
|
||||||
int tsdbEncodeDFileSet(void **buf, SDFileSet *pSet);
|
|
||||||
void *tsdbDecodeDFileSet(STsdb *pRepo, void *buf, SDFileSet *pSet);
|
|
||||||
int tsdbEncodeDFileSetEx(void **buf, SDFileSet *pSet);
|
|
||||||
void *tsdbDecodeDFileSetEx(void *buf, SDFileSet *pSet);
|
|
||||||
int tsdbApplyDFileSetChange(SDFileSet *from, SDFileSet *to);
|
|
||||||
int tsdbCreateDFileSet(STsdb *pRepo, SDFileSet *pSet, bool updateHeader);
|
|
||||||
int tsdbUpdateDFileSetHeader(SDFileSet *pSet);
|
|
||||||
int tsdbScanAndTryFixDFileSet(STsdb *pRepo, SDFileSet *pSet);
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbCloseDFileSet(SDFileSet *pSet) {
|
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
|
||||||
tsdbCloseDFile(TSDB_DFILE_IN_SET(pSet, ftype));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbOpenDFileSet(SDFileSet *pSet, int flags) {
|
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
|
||||||
if (tsdbOpenDFile(TSDB_DFILE_IN_SET(pSet, ftype), flags) < 0) {
|
|
||||||
tsdbCloseDFileSet(pSet);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbRemoveDFileSet(SDFileSet *pSet) {
|
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
|
||||||
(void)tsdbRemoveDFile(TSDB_DFILE_IN_SET(pSet, ftype));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbCopyDFileSet(SDFileSet *pSrc, SDFileSet *pDest) {
|
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
|
||||||
if (tsdbCopyDFile(TSDB_DFILE_IN_SET(pSrc, ftype), TSDB_DFILE_IN_SET(pDest, ftype)) < 0) {
|
|
||||||
tsdbRemoveDFileSet(pDest);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE void tsdbGetFidKeyRange(int days, int8_t precision, int fid, TSKEY *minKey, TSKEY *maxKey) {
|
|
||||||
*minKey = fid * days * tsTickPerMin[precision];
|
|
||||||
*maxKey = *minKey + days * tsTickPerMin[precision] - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet *pSet) {
|
static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet *pSet) {
|
||||||
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
if (TSDB_FILE_IS_BAD(TSDB_DFILE_IN_SET(pSet, ftype))) {
|
if (TSDB_FILE_IS_BAD(TSDB_DFILE_IN_SET(pSet, ftype))) {
|
||||||
|
|
@ -803,69 +638,26 @@ typedef struct {
|
||||||
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
|
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
|
||||||
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
|
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
|
||||||
|
|
||||||
typedef struct {
|
struct SFSIter {
|
||||||
int direction;
|
int direction;
|
||||||
uint64_t version; // current FS version
|
uint64_t version; // current FS version
|
||||||
STsdbFS *pfs;
|
STsdbFS *pfs;
|
||||||
int index; // used to position next fset when version the same
|
int index; // used to position next fset when version the same
|
||||||
int fid; // used to seek when version is changed
|
int fid; // used to seek when version is changed
|
||||||
SDFileSet *pSet;
|
SDFileSet *pSet;
|
||||||
} SFSIter;
|
};
|
||||||
|
|
||||||
#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
|
#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
|
||||||
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
|
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
|
||||||
|
|
||||||
STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg);
|
|
||||||
void *tsdbFreeFS(STsdbFS *pfs);
|
|
||||||
int tsdbOpenFS(STsdb *pRepo);
|
|
||||||
void tsdbCloseFS(STsdb *pRepo);
|
|
||||||
void tsdbStartFSTxn(STsdb *pRepo, int64_t pointsAdd, int64_t storageAdd);
|
|
||||||
int tsdbEndFSTxn(STsdb *pRepo);
|
|
||||||
int tsdbEndFSTxnWithError(STsdbFS *pfs);
|
|
||||||
void tsdbUpdateFSTxnMeta(STsdbFS *pfs, STsdbFSMeta *pMeta);
|
|
||||||
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
|
|
||||||
int tsdbUpdateDFileSet(STsdbFS *pfs, const SDFileSet *pSet);
|
|
||||||
|
|
||||||
void tsdbFSIterInit(SFSIter *pIter, STsdbFS *pfs, int direction);
|
|
||||||
void tsdbFSIterSeek(SFSIter *pIter, int fid);
|
|
||||||
SDFileSet *tsdbFSIterNext(SFSIter *pIter);
|
|
||||||
int tsdbLoadMetaCache(STsdb *pRepo, bool recoverMeta);
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbRLockFS(STsdbFS *pFs) {
|
|
||||||
int code = taosThreadRwlockRdlock(&(pFs->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbWLockFS(STsdbFS *pFs) {
|
|
||||||
int code = taosThreadRwlockWrlock(&(pFs->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbUnLockFS(STsdbFS *pFs) {
|
|
||||||
int code = taosThreadRwlockUnlock(&(pFs->lock));
|
|
||||||
if (code != 0) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(code);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TSDBROW {
|
struct TSDBROW {
|
||||||
int64_t version;
|
int64_t version;
|
||||||
STSRow2 tsRow;
|
STSRow2 tsRow;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TSDBKEY {
|
struct TABLEID {
|
||||||
int64_t version;
|
tb_uid_t suid;
|
||||||
TSKEY ts;
|
tb_uid_t uid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDelOp {
|
struct SDelOp {
|
||||||
|
|
@ -875,6 +667,25 @@ struct SDelOp {
|
||||||
SDelOp *pNext;
|
SDelOp *pNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tb_uid_t suid;
|
||||||
|
tb_uid_t uid;
|
||||||
|
int64_t version;
|
||||||
|
TSKEY sKey;
|
||||||
|
TSKEY eKey;
|
||||||
|
} SDelInfo;
|
||||||
|
|
||||||
|
struct SMemTable {
|
||||||
|
STsdb *pTsdb;
|
||||||
|
int32_t nRef;
|
||||||
|
TSDBKEY minKey;
|
||||||
|
TSDBKEY maxKey;
|
||||||
|
int64_t nRows;
|
||||||
|
int64_t nDelOp;
|
||||||
|
SArray *aSkmInfo;
|
||||||
|
SArray *aMemData;
|
||||||
|
};
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbKeyCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
TSDBKEY *pKey1 = (TSDBKEY *)p1;
|
||||||
TSDBKEY *pKey2 = (TSDBKEY *)p2;
|
TSDBKEY *pKey2 = (TSDBKEY *)p2;
|
||||||
|
|
@ -894,6 +705,34 @@ static FORCE_INLINE int tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SMemSkipListNode SMemSkipListNode;
|
||||||
|
typedef struct SMemSkipList {
|
||||||
|
uint32_t seed;
|
||||||
|
int32_t size;
|
||||||
|
int8_t maxLevel;
|
||||||
|
int8_t level;
|
||||||
|
SMemSkipListNode *pHead;
|
||||||
|
SMemSkipListNode *pTail;
|
||||||
|
} SMemSkipList;
|
||||||
|
|
||||||
|
struct SMemData {
|
||||||
|
tb_uid_t suid;
|
||||||
|
tb_uid_t uid;
|
||||||
|
TSDBKEY minKey;
|
||||||
|
TSDBKEY maxKey;
|
||||||
|
SDelOp *delOpHead;
|
||||||
|
SDelOp *delOpTail;
|
||||||
|
SMemSkipList sl;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SMemDataIter {
|
||||||
|
SMemData *pMemData;
|
||||||
|
int8_t backward;
|
||||||
|
TSDBROW *pRow;
|
||||||
|
SMemSkipListNode *pNode; // current node
|
||||||
|
TSDBROW row;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppRea
|
||||||
int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader);
|
int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader);
|
||||||
int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData);
|
int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData);
|
||||||
void* metaGetIdx(SMeta* pMeta);
|
void* metaGetIdx(SMeta* pMeta);
|
||||||
|
void* metaGetIvtIdx(SMeta* pMeta);
|
||||||
|
|
||||||
int32_t metaCreateTSma(SMeta* pMeta, int64_t version, SSmaCfg* pCfg);
|
int32_t metaCreateTSma(SMeta* pMeta, int64_t version, SSmaCfg* pCfg);
|
||||||
int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
||||||
|
|
@ -112,7 +113,7 @@ int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid);
|
||||||
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg);
|
int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg);
|
||||||
int tsdbClose(STsdb** pTsdb);
|
int tsdbClose(STsdb** pTsdb);
|
||||||
int tsdbBegin(STsdb* pTsdb);
|
int tsdbBegin(STsdb* pTsdb);
|
||||||
int tsdbCommit(STsdb* pTsdb);
|
int32_t tsdbCommit(STsdb* pTsdb);
|
||||||
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq* pMsg);
|
int tsdbScanAndConvertSubmitMsg(STsdb* pTsdb, SSubmitReq* pMsg);
|
||||||
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSubmitRsp* pRsp);
|
||||||
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
int tsdbInsertTableData(STsdb* pTsdb, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock, SSubmitBlkRsp* pRsp);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// open pTagIdx
|
// open pTagIdx
|
||||||
#ifdef USE_INVERTED_INDEX
|
|
||||||
// TODO(yihaoDeng), refactor later
|
// TODO(yihaoDeng), refactor later
|
||||||
char indexFullPath[128] = {0};
|
char indexFullPath[128] = {0};
|
||||||
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
|
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
|
||||||
|
|
@ -104,13 +103,11 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
ret = tdbTbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx);
|
ret = tdbTbOpen("tag.idx", -1, 0, tagIdxKeyCmpr, pMeta->pEnv, &pMeta->pTagIdx);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaError("vgId:%d, failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
metaError("vgId:%d, failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// open pTtlIdx
|
// open pTtlIdx
|
||||||
ret = tdbTbOpen("ttl.idx", sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, pMeta->pEnv, &pMeta->pTtlIdx);
|
ret = tdbTbOpen("ttl.idx", sizeof(STtlIdxKey), 0, ttlIdxKeyCmpr, pMeta->pEnv, &pMeta->pTtlIdx);
|
||||||
|
|
@ -141,11 +138,8 @@ _err:
|
||||||
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
if (pMeta->pIdx) metaCloseIdx(pMeta);
|
||||||
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
if (pMeta->pSmaIdx) tdbTbClose(pMeta->pSmaIdx);
|
||||||
if (pMeta->pTtlIdx) tdbTbClose(pMeta->pTtlIdx);
|
if (pMeta->pTtlIdx) tdbTbClose(pMeta->pTtlIdx);
|
||||||
#ifdef USE_INVERTED_INDEX
|
|
||||||
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
if (pMeta->pTagIvtIdx) indexClose(pMeta->pTagIvtIdx);
|
||||||
#else
|
|
||||||
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
if (pMeta->pTagIdx) tdbTbClose(pMeta->pTagIdx);
|
||||||
#endif
|
|
||||||
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
if (pMeta->pCtbIdx) tdbTbClose(pMeta->pCtbIdx);
|
||||||
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
if (pMeta->pNameIdx) tdbTbClose(pMeta->pNameIdx);
|
||||||
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
if (pMeta->pUidIdx) tdbTbClose(pMeta->pUidIdx);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
|
|
||||||
|
static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
||||||
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||||
|
|
@ -43,6 +44,68 @@ static int metaUpdateMetaRsp(tb_uid_t uid, char* tbName, SSchemaWrapper *pSchema
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema) {
|
||||||
|
#ifdef USE_INVERTED_INDEX
|
||||||
|
if (pMeta->pTagIvtIdx == NULL || pCtbEntry == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
void * data = pCtbEntry->ctbEntry.pTags;
|
||||||
|
const char *tagName = pSchema->name;
|
||||||
|
|
||||||
|
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
||||||
|
tb_uid_t tuid = pCtbEntry->uid;
|
||||||
|
const void *pTagData = pCtbEntry->ctbEntry.pTags;
|
||||||
|
int32_t nTagData = 0;
|
||||||
|
|
||||||
|
SArray *pTagVals = NULL;
|
||||||
|
if (tTagToValArray((const STag *)data, &pTagVals) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
char key[512] = {0};
|
||||||
|
|
||||||
|
SIndexMultiTerm *terms = indexMultiTermCreate();
|
||||||
|
int16_t nCols = taosArrayGetSize(pTagVals);
|
||||||
|
for (int i = 0; i < nCols; i++) {
|
||||||
|
STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
|
||||||
|
char type = pTagVal->type;
|
||||||
|
sprintf(key, "%s_%s", tagName, pTagVal->pKey);
|
||||||
|
int32_t nKey = strlen(key);
|
||||||
|
|
||||||
|
SIndexTerm *term = NULL;
|
||||||
|
if (type == TSDB_DATA_TYPE_NULL) {
|
||||||
|
// handle null value
|
||||||
|
} else if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
if (pTagVal->nData > 0) {
|
||||||
|
char * val = taosMemoryCalloc(1, pTagVal->nData + VARSTR_HEADER_SIZE);
|
||||||
|
int32_t len = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, val + VARSTR_HEADER_SIZE);
|
||||||
|
memcpy(val, (uint16_t *)&len, VARSTR_HEADER_SIZE);
|
||||||
|
type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, val, len);
|
||||||
|
} else if (pTagVal->nData == 0) {
|
||||||
|
char * val = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
|
// handle NULL key
|
||||||
|
}
|
||||||
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
double val = *(double *)(&pTagVal->i64);
|
||||||
|
int len = 0;
|
||||||
|
term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len);
|
||||||
|
} else if (type == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
int val = *(int *)(&pTagVal->i64);
|
||||||
|
int len = 0;
|
||||||
|
term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len);
|
||||||
|
}
|
||||||
|
if (term != NULL) {
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
|
}
|
||||||
|
memset(key, 0, sizeof(key));
|
||||||
|
}
|
||||||
|
tIndexJsonPut(pMeta->pTagIvtIdx, terms, tuid);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||||
SMetaEntry me = {0};
|
SMetaEntry me = {0};
|
||||||
int kLen = 0;
|
int kLen = 0;
|
||||||
|
|
@ -341,7 +404,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) {
|
||||||
void * pVal = NULL;
|
void * pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
|
|
@ -824,28 +886,16 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
|
||||||
} else {
|
} else {
|
||||||
// pTagData = pCtbEntry->ctbEntry.pTags;
|
// pTagData = pCtbEntry->ctbEntry.pTags;
|
||||||
// nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len;
|
// nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len;
|
||||||
|
pTagData = pCtbEntry->ctbEntry.pTags;
|
||||||
|
nTagData = ((const STag *)pCtbEntry->ctbEntry.pTags)->len;
|
||||||
|
return metaSaveJsonVarToIdx(pMeta, pCtbEntry, pTagColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update tag index
|
|
||||||
#ifdef USE_INVERTED_INDEX
|
|
||||||
tb_uid_t suid = pCtbEntry->ctbEntry.suid;
|
|
||||||
tb_uid_t tuid = pCtbEntry->uid;
|
|
||||||
|
|
||||||
SIndexMultiTerm *tmGroup = indexMultiTermCreate();
|
|
||||||
|
|
||||||
SIndexTerm *tm = indexTermCreate(suid, ADD_VALUE, pTagColumn->type, pTagColumn->name, sizeof(pTagColumn->name),
|
|
||||||
pTagData, pTagData == NULL ? 0 : strlen(pTagData));
|
|
||||||
indexMultiTermAdd(tmGroup, tm);
|
|
||||||
int ret = indexPut((SIndex *)pMeta->pTagIvtIdx, tmGroup, tuid);
|
|
||||||
indexMultiTermDestroy(tmGroup);
|
|
||||||
#else
|
|
||||||
if (metaCreateTagIdxKey(pCtbEntry->ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type,
|
if (metaCreateTagIdxKey(pCtbEntry->ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type,
|
||||||
pCtbEntry->uid, &pTagIdxKey, &nTagIdxKey) < 0) {
|
pCtbEntry->uid, &pTagIdxKey, &nTagIdxKey) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tdbTbInsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn);
|
tdbTbInsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn);
|
||||||
metaDestroyTagIdxKey(pTagIdxKey);
|
metaDestroyTagIdxKey(pTagIdxKey);
|
||||||
#endif
|
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
tdbFree(pData);
|
tdbFree(pData);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -930,10 +980,5 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// refactor later
|
// refactor later
|
||||||
void *metaGetIdx(SMeta *pMeta) {
|
void *metaGetIdx(SMeta *pMeta) { return pMeta->pTagIdx; }
|
||||||
#ifdef USE_INVERTED_INDEX
|
void *metaGetIvtIdx(SMeta *pMeta) { return pMeta->pTagIvtIdx; }
|
||||||
return pMeta->pTagIvtIdx;
|
|
||||||
#else
|
|
||||||
return pMeta->pTagIdx;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,11 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayGetSize(pResult) > 0) {
|
if (taosArrayGetSize(pResult) > 0) {
|
||||||
blockDebugShowData(pResult);
|
#if 1
|
||||||
|
char flag[10] = {0};
|
||||||
|
snprintf(flag, 10, "level %" PRIi8, level);
|
||||||
|
blockDebugShowData(pResult, flag);
|
||||||
|
#endif
|
||||||
STsdb *sinkTsdb = (level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2);
|
STsdb *sinkTsdb = (level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb1 : pSma->pRSmaTsdb2);
|
||||||
SSubmitReq *pReq = NULL;
|
SSubmitReq *pReq = NULL;
|
||||||
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) != 0) {
|
if (buildSubmitReqFromDataBlock(&pReq, pResult, pTSchema, SMA_VID(pSma), suid) != 0) {
|
||||||
|
|
@ -444,7 +448,7 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
if (inputType == STREAM_DATA_TYPE_SUBMIT_BLOCK) {
|
||||||
// TODO: use the proper schema instead of 0, and cache STSchema in cache
|
// TODO: cache STSchema
|
||||||
STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), suid, -1);
|
STSchema *pTSchema = metaGetTbTSchema(SMA_META(pSma), suid, -1);
|
||||||
if (!pTSchema) {
|
if (!pTSchema) {
|
||||||
terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION;
|
terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ static void tsdbCloseCommitFile(SCommitH *pCommith, bool hasError);
|
||||||
static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *pInfo);
|
static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *pInfo);
|
||||||
static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter,
|
static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter,
|
||||||
SDataCols *pTarget, TSKEY maxKey, int maxRows, int8_t update);
|
SDataCols *pTarget, TSKEY maxKey, int maxRows, int8_t update);
|
||||||
int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf);
|
static int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf);
|
||||||
|
static int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn);
|
||||||
|
|
||||||
int tsdbBegin(STsdb *pTsdb) {
|
int tsdbBegin(STsdb *pTsdb) {
|
||||||
if (!pTsdb) return 0;
|
if (!pTsdb) return 0;
|
||||||
|
|
@ -100,7 +101,81 @@ int tsdbBegin(STsdb *pTsdb) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) {
|
int32_t tsdbCommit(STsdb *pTsdb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SCommitH commith = {0};
|
||||||
|
SDFileSet *pSet = NULL;
|
||||||
|
int fid;
|
||||||
|
|
||||||
|
ASSERT(pTsdb->imem == NULL && pTsdb->mem);
|
||||||
|
pTsdb->imem = pTsdb->mem;
|
||||||
|
pTsdb->mem = NULL;
|
||||||
|
|
||||||
|
// start commit
|
||||||
|
tsdbStartCommit(pTsdb);
|
||||||
|
if (tsdbInitCommitH(&commith, pTsdb) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip expired memory data and expired FSET
|
||||||
|
tsdbSeekCommitIter(&commith, commith.rtn.minKey);
|
||||||
|
while ((pSet = tsdbFSIterNext(&(commith.fsIter)))) {
|
||||||
|
if (pSet->fid < commith.rtn.minFid) {
|
||||||
|
tsdbInfo("vgId:%d, FSET %d on level %d disk id %d expires, remove it", REPO_ID(pTsdb), pSet->fid,
|
||||||
|
TSDB_FSET_LEVEL(pSet), TSDB_FSET_ID(pSet));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit
|
||||||
|
fid = tsdbNextCommitFid(&(commith));
|
||||||
|
while (true) {
|
||||||
|
// Loop over both on disk and memory
|
||||||
|
if (pSet == NULL && fid == TSDB_IVLD_FID) break;
|
||||||
|
|
||||||
|
if (pSet && (fid == TSDB_IVLD_FID || pSet->fid < fid)) {
|
||||||
|
// Only has existing FSET but no memory data to commit in this
|
||||||
|
// existing FSET, only check if file in correct retention
|
||||||
|
if (tsdbApplyRtnOnFSet(pTsdb, pSet, &(commith.rtn)) < 0) {
|
||||||
|
tsdbDestroyCommitH(&commith);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSet = tsdbFSIterNext(&(commith.fsIter));
|
||||||
|
} else {
|
||||||
|
// Has memory data to commit
|
||||||
|
SDFileSet *pCSet;
|
||||||
|
int cfid;
|
||||||
|
|
||||||
|
if (pSet == NULL || pSet->fid > fid) {
|
||||||
|
// Commit to a new FSET with fid: fid
|
||||||
|
pCSet = NULL;
|
||||||
|
cfid = fid;
|
||||||
|
} else {
|
||||||
|
// Commit to an existing FSET
|
||||||
|
pCSet = pSet;
|
||||||
|
cfid = pSet->fid;
|
||||||
|
pSet = tsdbFSIterNext(&(commith.fsIter));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbCommitToFile(&commith, pCSet, cfid) < 0) {
|
||||||
|
tsdbDestroyCommitH(&commith);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fid = tsdbNextCommitFid(&commith);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// end commit
|
||||||
|
tsdbDestroyCommitH(&commith);
|
||||||
|
tsdbEndCommit(pTsdb, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) {
|
||||||
SDiskID did;
|
SDiskID did;
|
||||||
SDFileSet nSet = {0};
|
SDFileSet nSet = {0};
|
||||||
STsdbFS *pfs = REPO_FS(pRepo);
|
STsdbFS *pfs = REPO_FS(pRepo);
|
||||||
|
|
@ -141,87 +216,15 @@ int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbPrepareCommit(STsdb *pTsdb) {
|
// int tsdbPrepareCommit(STsdb *pTsdb) {
|
||||||
if (pTsdb->mem == NULL) return 0;
|
// if (pTsdb->mem == NULL) return 0;
|
||||||
|
|
||||||
ASSERT(pTsdb->imem == NULL);
|
// ASSERT(pTsdb->imem == NULL);
|
||||||
|
|
||||||
pTsdb->imem = pTsdb->mem;
|
// pTsdb->imem = pTsdb->mem;
|
||||||
pTsdb->mem = NULL;
|
// pTsdb->mem = NULL;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int tsdbCommit(STsdb *pRepo) {
|
|
||||||
SCommitH commith = {0};
|
|
||||||
SDFileSet *pSet = NULL;
|
|
||||||
int fid;
|
|
||||||
|
|
||||||
// if (pRepo->imem == NULL) return 0;
|
|
||||||
pRepo->imem = pRepo->mem;
|
|
||||||
pRepo->mem = NULL;
|
|
||||||
|
|
||||||
tsdbStartCommit(pRepo);
|
|
||||||
// Resource initialization
|
|
||||||
if (tsdbInitCommitH(&commith, pRepo) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip expired memory data and expired FSET
|
|
||||||
tsdbSeekCommitIter(&commith, commith.rtn.minKey);
|
|
||||||
while ((pSet = tsdbFSIterNext(&(commith.fsIter)))) {
|
|
||||||
if (pSet->fid < commith.rtn.minFid) {
|
|
||||||
tsdbInfo("vgId:%d, FSET %d on level %d disk id %d expires, remove it", REPO_ID(pRepo), pSet->fid,
|
|
||||||
TSDB_FSET_LEVEL(pSet), TSDB_FSET_ID(pSet));
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop to commit to each file
|
|
||||||
fid = tsdbNextCommitFid(&(commith));
|
|
||||||
while (true) {
|
|
||||||
// Loop over both on disk and memory
|
|
||||||
if (pSet == NULL && fid == TSDB_IVLD_FID) break;
|
|
||||||
|
|
||||||
if (pSet && (fid == TSDB_IVLD_FID || pSet->fid < fid)) {
|
|
||||||
// Only has existing FSET but no memory data to commit in this
|
|
||||||
// existing FSET, only check if file in correct retention
|
|
||||||
if (tsdbApplyRtnOnFSet(pRepo, pSet, &(commith.rtn)) < 0) {
|
|
||||||
tsdbDestroyCommitH(&commith);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pSet = tsdbFSIterNext(&(commith.fsIter));
|
|
||||||
} else {
|
|
||||||
// Has memory data to commit
|
|
||||||
SDFileSet *pCSet;
|
|
||||||
int cfid;
|
|
||||||
|
|
||||||
if (pSet == NULL || pSet->fid > fid) {
|
|
||||||
// Commit to a new FSET with fid: fid
|
|
||||||
pCSet = NULL;
|
|
||||||
cfid = fid;
|
|
||||||
} else {
|
|
||||||
// Commit to an existing FSET
|
|
||||||
pCSet = pSet;
|
|
||||||
cfid = pSet->fid;
|
|
||||||
pSet = tsdbFSIterNext(&(commith.fsIter));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tsdbCommitToFile(&commith, pCSet, cfid) < 0) {
|
|
||||||
tsdbDestroyCommitH(&commith);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fid = tsdbNextCommitFid(&commith);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbDestroyCommitH(&commith);
|
|
||||||
tsdbEndCommit(pRepo, TSDB_CODE_SUCCESS);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
|
void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
|
||||||
STsdbKeepCfg *pCfg = REPO_KEEP_CFG(pRepo);
|
STsdbKeepCfg *pCfg = REPO_KEEP_CFG(pRepo);
|
||||||
|
|
@ -543,8 +546,8 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("vgId:%d, FSET %d at level %d disk id %d is opened to read to commit", REPO_ID(pRepo), TSDB_FSET_FID(pSet),
|
tsdbDebug("vgId:%d, FSET %d at level %d disk id %d is opened to read to commit", REPO_ID(pRepo),
|
||||||
TSDB_FSET_LEVEL(pSet), TSDB_FSET_ID(pSet));
|
TSDB_FSET_FID(pSet), TSDB_FSET_LEVEL(pSet), TSDB_FSET_ID(pSet));
|
||||||
} else {
|
} else {
|
||||||
pCommith->isRFileSet = false;
|
pCommith->isRFileSet = false;
|
||||||
}
|
}
|
||||||
|
|
@ -716,7 +719,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
|
||||||
|
|
||||||
// extern int32_t tsTsdbMetaCompactRatio;
|
// extern int32_t tsTsdbMetaCompactRatio;
|
||||||
|
|
||||||
int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray *pSubA, void **ppBuf,
|
static int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray *pSubA, void **ppBuf,
|
||||||
SBlockIdx *pIdx) {
|
SBlockIdx *pIdx) {
|
||||||
size_t nSupBlocks;
|
size_t nSupBlocks;
|
||||||
size_t nSubBlocks;
|
size_t nSubBlocks;
|
||||||
|
|
@ -769,7 +772,7 @@ int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray
|
||||||
|
|
||||||
pIdx->uid = TABLE_UID(pTable);
|
pIdx->uid = TABLE_UID(pTable);
|
||||||
pIdx->hasLast = pBlock->last ? 1 : 0;
|
pIdx->hasLast = pBlock->last ? 1 : 0;
|
||||||
pIdx->maxKey = pBlock->keyLast;
|
pIdx->maxKey = pBlock->maxKey;
|
||||||
pIdx->numOfBlocks = (uint32_t)nSupBlocks;
|
pIdx->numOfBlocks = (uint32_t)nSupBlocks;
|
||||||
pIdx->len = tlen;
|
pIdx->len = tlen;
|
||||||
pIdx->offset = (uint32_t)offset;
|
pIdx->offset = (uint32_t)offset;
|
||||||
|
|
@ -777,7 +780,7 @@ int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
|
static int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
|
||||||
SBlockIdx *pBlkIdx;
|
SBlockIdx *pBlkIdx;
|
||||||
size_t nidx = taosArrayGetSize(pIdxA);
|
size_t nidx = taosArrayGetSize(pIdxA);
|
||||||
int tlen = 0, size;
|
int tlen = 0, size;
|
||||||
|
|
@ -890,7 +893,7 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tsdbCommitMemData(pCommith, pIter, pBlock->keyFirst - 1, true) < 0) {
|
if (tsdbCommitMemData(pCommith, pIter, pBlock->minKey.ts - 1, true) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -985,9 +988,9 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
|
||||||
TSKEY key = *(TSKEY *)arg1;
|
TSKEY key = *(TSKEY *)arg1;
|
||||||
SBlock *pBlock = (SBlock *)arg2;
|
SBlock *pBlock = (SBlock *)arg2;
|
||||||
|
|
||||||
if (key < pBlock->keyFirst) {
|
if (key < pBlock->minKey.ts) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (key > pBlock->keyLast) {
|
} else if (key > pBlock->maxKey.ts) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1011,7 +1014,7 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
|
||||||
* @param ppExBuf
|
* @param ppExBuf
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDFileAggr, SDataCols *pDataCols,
|
static int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDFileAggr, SDataCols *pDataCols,
|
||||||
SBlock *pBlock, bool isLast, bool isSuper, void **ppBuf, void **ppCBuf, void **ppExBuf) {
|
SBlock *pBlock, bool isLast, bool isSuper, void **ppBuf, void **ppCBuf, void **ppExBuf) {
|
||||||
STsdbCfg *pCfg = REPO_CFG(pRepo);
|
STsdbCfg *pCfg = REPO_CFG(pRepo);
|
||||||
SBlockData *pBlockData = NULL;
|
SBlockData *pBlockData = NULL;
|
||||||
|
|
@ -1170,7 +1173,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
tsdbUpdateDFileMagic(pDFile, POINTER_SHIFT(tptr, flen - sizeof(TSCKSUM)));
|
tsdbUpdateDFileMagic(pDFile, POINTER_SHIFT(tptr, flen - sizeof(TSCKSUM)));
|
||||||
|
|
||||||
if (ncol != 0) {
|
if (ncol != 0) {
|
||||||
tsdbSetBlockColOffset(pBlockCol, toffset);
|
pBlockCol->offset = toffset;
|
||||||
pBlockCol->len = flen; // data + bitmaps
|
pBlockCol->len = flen; // data + bitmaps
|
||||||
pBlockCol->blen = tBitmapsLen;
|
pBlockCol->blen = tBitmapsLen;
|
||||||
++tcol;
|
++tcol;
|
||||||
|
|
@ -1215,8 +1218,8 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
pBlock->numOfSubBlocks = isSuper ? 1 : 0;
|
pBlock->numOfSubBlocks = isSuper ? 1 : 0;
|
||||||
pBlock->numOfCols = nColsNotAllNull;
|
pBlock->numOfCols = nColsNotAllNull;
|
||||||
pBlock->numOfBSma = nColsOfBlockSma;
|
pBlock->numOfBSma = nColsOfBlockSma;
|
||||||
pBlock->keyFirst = dataColsKeyFirst(pDataCols);
|
pBlock->minKey.ts = dataColsKeyFirst(pDataCols);
|
||||||
pBlock->keyLast = dataColsKeyLast(pDataCols);
|
pBlock->maxKey.ts = dataColsKeyLast(pDataCols);
|
||||||
pBlock->aggrStat = aggrStatus;
|
pBlock->aggrStat = aggrStatus;
|
||||||
pBlock->blkVer = SBlockVerLatest;
|
pBlock->blkVer = SBlockVerLatest;
|
||||||
pBlock->aggrOffset = (uint64_t)offsetAggr;
|
pBlock->aggrOffset = (uint64_t)offsetAggr;
|
||||||
|
|
@ -1224,7 +1227,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
||||||
tsdbDebug("vgId:%d, uid:%" PRId64 " a block of data is written to file %s, offset %" PRId64
|
tsdbDebug("vgId:%d, uid:%" PRId64 " a block of data is written to file %s, offset %" PRId64
|
||||||
" numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64,
|
" numOfRows %d len %d numOfCols %" PRId16 " keyFirst %" PRId64 " keyLast %" PRId64,
|
||||||
REPO_ID(pRepo), TABLE_UID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len,
|
REPO_ID(pRepo), TABLE_UID(pTable), TSDB_FILE_FULL_NAME(pDFile), offset, rowsToWrite, pBlock->len,
|
||||||
pBlock->numOfCols, pBlock->keyFirst, pBlock->keyLast);
|
pBlock->numOfCols, pBlock->minKey.ts, pBlock->maxKey.ts);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1307,7 +1310,7 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
|
||||||
if (bidx == nBlocks - 1) {
|
if (bidx == nBlocks - 1) {
|
||||||
keyLimit = pCommith->maxKey;
|
keyLimit = pCommith->maxKey;
|
||||||
} else {
|
} else {
|
||||||
keyLimit = pBlock[1].keyFirst - 1;
|
keyLimit = pBlock[1].minKey.ts - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSkipListIterator titer = *(pIter->pIter);
|
SSkipListIterator titer = *(pIter->pIter);
|
||||||
|
|
@ -1349,8 +1352,8 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) {
|
||||||
}
|
}
|
||||||
subBlocks[pBlock->numOfSubBlocks] = block;
|
subBlocks[pBlock->numOfSubBlocks] = block;
|
||||||
supBlock = *pBlock;
|
supBlock = *pBlock;
|
||||||
supBlock.keyFirst = mInfo.keyFirst;
|
supBlock.minKey.ts = mInfo.keyFirst;
|
||||||
supBlock.keyLast = mInfo.keyLast;
|
supBlock.maxKey.ts = mInfo.keyLast;
|
||||||
supBlock.numOfSubBlocks++;
|
supBlock.numOfSubBlocks++;
|
||||||
supBlock.numOfRows = pBlock->numOfRows + mInfo.rowsInserted - mInfo.rowsDeleteSucceed;
|
supBlock.numOfRows = pBlock->numOfRows + mInfo.rowsInserted - mInfo.rowsDeleteSucceed;
|
||||||
supBlock.offset = taosArrayGetSize(pCommith->aSubBlk) * sizeof(SBlock);
|
supBlock.offset = taosArrayGetSize(pCommith->aSubBlk) * sizeof(SBlock);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,436 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tsdb.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMemTable *pMemTable;
|
||||||
|
int32_t minutes;
|
||||||
|
int8_t precision;
|
||||||
|
TSKEY nCommitKey;
|
||||||
|
int32_t fid;
|
||||||
|
TSKEY minKey;
|
||||||
|
TSKEY maxKey;
|
||||||
|
SReadH readh;
|
||||||
|
SDFileSet wSet;
|
||||||
|
SArray *aBlkIdx;
|
||||||
|
SArray *aSupBlk;
|
||||||
|
SArray *aSubBlk;
|
||||||
|
SArray *aDelInfo;
|
||||||
|
} SCommitH;
|
||||||
|
|
||||||
|
static int32_t tsdbCommitStart(SCommitH *pCHandle, STsdb *pTsdb);
|
||||||
|
static int32_t tsdbCommitEnd(SCommitH *pCHandle);
|
||||||
|
static int32_t tsdbCommitImpl(SCommitH *pCHandle);
|
||||||
|
|
||||||
|
int32_t tsdbBegin2(STsdb *pTsdb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
ASSERT(pTsdb->mem == NULL);
|
||||||
|
code = tsdbMemTableCreate2(pTsdb, (SMemTable **)&pTsdb->mem);
|
||||||
|
if (code) {
|
||||||
|
tsdbError("vgId:%d failed to begin TSDB since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tsdbCommit2(STsdb *pTsdb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SCommitH ch = {0};
|
||||||
|
|
||||||
|
// start to commit
|
||||||
|
code = tsdbCommitStart(&ch, pTsdb);
|
||||||
|
if (code) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit
|
||||||
|
code = tsdbCommitImpl(&ch);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// end commit
|
||||||
|
code = tsdbCommitEnd(&ch);
|
||||||
|
if (code) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
tsdbError("vgId:%d failed to commit since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitStart(SCommitH *pCHandle, STsdb *pTsdb) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMemTable *pMemTable = (SMemTable *)pTsdb->mem;
|
||||||
|
|
||||||
|
tsdbInfo("vgId:%d start to commit", TD_VID(pTsdb->pVnode));
|
||||||
|
|
||||||
|
// switch to commit
|
||||||
|
ASSERT(pTsdb->imem == NULL && pTsdb->mem);
|
||||||
|
pTsdb->imem = pTsdb->mem;
|
||||||
|
pTsdb->mem = NULL;
|
||||||
|
|
||||||
|
// open handle
|
||||||
|
pCHandle->pMemTable = pMemTable;
|
||||||
|
pCHandle->minutes = pTsdb->keepCfg.days;
|
||||||
|
pCHandle->precision = pTsdb->keepCfg.precision;
|
||||||
|
pCHandle->nCommitKey = pMemTable->minKey.ts;
|
||||||
|
|
||||||
|
code = tsdbInitReadH(&pCHandle->readh, pTsdb);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
pCHandle->aBlkIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||||
|
if (pCHandle->aBlkIdx == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
pCHandle->aSupBlk = taosArrayInit(0, sizeof(SBlock));
|
||||||
|
if (pCHandle->aSupBlk == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
pCHandle->aSubBlk = taosArrayInit(0, sizeof(SBlock));
|
||||||
|
if (pCHandle->aSubBlk == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
pCHandle->aDelInfo = taosArrayInit(0, sizeof(SDelInfo));
|
||||||
|
if (pCHandle->aDelInfo == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start FS transaction
|
||||||
|
tsdbStartFSTxn(pTsdb, 0, 0);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitEnd(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
STsdb *pTsdb = pCHandle->pMemTable->pTsdb;
|
||||||
|
SMemTable *pMemTable = (SMemTable *)pTsdb->imem;
|
||||||
|
|
||||||
|
// end transaction
|
||||||
|
code = tsdbEndFSTxn(pTsdb);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// close handle
|
||||||
|
taosArrayClear(pCHandle->aDelInfo);
|
||||||
|
taosArrayClear(pCHandle->aSubBlk);
|
||||||
|
taosArrayClear(pCHandle->aSupBlk);
|
||||||
|
taosArrayClear(pCHandle->aBlkIdx);
|
||||||
|
tsdbDestroyReadH(&pCHandle->readh);
|
||||||
|
|
||||||
|
// destroy memtable (todo: unref it)
|
||||||
|
pTsdb->imem = NULL;
|
||||||
|
tsdbMemTableDestroy2(pMemTable);
|
||||||
|
|
||||||
|
tsdbInfo("vgId:%d commit over", TD_VID(pTsdb->pVnode));
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitTableStart(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitTableEnd(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitTable(SCommitH *pCHandle, SMemData *pMemData, SBlockIdx *pBlockIdx) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMemDataIter iter = {0};
|
||||||
|
|
||||||
|
// commit table start
|
||||||
|
code = tsdbCommitTableStart(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit table impl
|
||||||
|
if (pMemData && pBlockIdx) {
|
||||||
|
// TODO
|
||||||
|
} else if (pMemData) {
|
||||||
|
// TODO
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit table end
|
||||||
|
code = tsdbCommitTableEnd(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbTableIdCmprFn(const void *p1, const void *p2) {
|
||||||
|
TABLEID *pId1 = (TABLEID *)p1;
|
||||||
|
TABLEID *pId2 = (TABLEID *)p2;
|
||||||
|
|
||||||
|
if (pId1->suid < pId2->suid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pId1->suid > pId2->suid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pId1->uid < pId2->uid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pId1->uid > pId2->uid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbWriteBlockIdx(SDFile *pFile, SArray *pArray, uint8_t **ppBuf) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitFileStart(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
STsdb *pTsdb = pCHandle->pMemTable->pTsdb;
|
||||||
|
SDFileSet *pSet = NULL;
|
||||||
|
|
||||||
|
taosArrayClear(pCHandle->aBlkIdx);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitFileEnd(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitFile(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SMemData *pMemData;
|
||||||
|
SBlockIdx *pBlockIdx;
|
||||||
|
int32_t iMemData;
|
||||||
|
int32_t nMemData;
|
||||||
|
int32_t iBlockIdx;
|
||||||
|
int32_t nBlockIdx;
|
||||||
|
|
||||||
|
// commit file start
|
||||||
|
code = tsdbCommitFileStart(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit file impl
|
||||||
|
iMemData = 0;
|
||||||
|
nMemData = taosArrayGetSize(pCHandle->pMemTable->aMemData);
|
||||||
|
iBlockIdx = 0;
|
||||||
|
nBlockIdx = 0; // todo
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (iMemData >= nMemData && iBlockIdx >= nBlockIdx) break;
|
||||||
|
|
||||||
|
pMemData = NULL;
|
||||||
|
pBlockIdx = NULL;
|
||||||
|
if (iMemData < nMemData) {
|
||||||
|
pMemData = (SMemData *)taosArrayGetP(pCHandle->pMemTable->aMemData, iMemData);
|
||||||
|
}
|
||||||
|
if (iBlockIdx < nBlockIdx) {
|
||||||
|
// pBlockIdx = ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMemData && pBlockIdx) {
|
||||||
|
int32_t c = tsdbTableIdCmprFn(pMemData, pBlockIdx);
|
||||||
|
if (c < 0) {
|
||||||
|
iMemData++;
|
||||||
|
pBlockIdx = NULL;
|
||||||
|
} else if (c == 0) {
|
||||||
|
iMemData++;
|
||||||
|
iBlockIdx++;
|
||||||
|
} else {
|
||||||
|
iBlockIdx++;
|
||||||
|
pMemData = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pMemData) {
|
||||||
|
iMemData++;
|
||||||
|
} else {
|
||||||
|
iBlockIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tsdbCommitTable(pCHandle, pMemData, pBlockIdx);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit file end
|
||||||
|
code = tsdbCommitFileEnd(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitData(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t fid;
|
||||||
|
|
||||||
|
if (pCHandle->pMemTable->nRows == 0) goto _exit;
|
||||||
|
|
||||||
|
// loop to commit to each file
|
||||||
|
for (;;) {
|
||||||
|
if (pCHandle->nCommitKey == TSKEY_MAX) break;
|
||||||
|
|
||||||
|
pCHandle->fid = TSDB_KEY_FID(pCHandle->nCommitKey, pCHandle->minutes, pCHandle->precision);
|
||||||
|
tsdbGetFidKeyRange(pCHandle->minutes, pCHandle->precision, pCHandle->fid, &pCHandle->minKey, &pCHandle->maxKey);
|
||||||
|
code = tsdbCommitFile(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t delInfoCmprFn(const void *p1, const void *p2) {
|
||||||
|
SDelInfo *pDelInfo1 = (SDelInfo *)p1;
|
||||||
|
SDelInfo *pDelInfo2 = (SDelInfo *)p2;
|
||||||
|
|
||||||
|
if (pDelInfo1->suid < pDelInfo2->suid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pDelInfo1->suid > pDelInfo2->suid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDelInfo1->uid < pDelInfo2->uid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pDelInfo1->uid > pDelInfo2->uid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDelInfo1->version < pDelInfo2->version) {
|
||||||
|
return -1;
|
||||||
|
} else if (pDelInfo1->version > pDelInfo2->version) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int32_t tsdbCommitDelete(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SDelInfo delInfo;
|
||||||
|
SMemData *pMemData;
|
||||||
|
|
||||||
|
if (pCHandle->pMemTable->nDelOp == 0) goto _exit;
|
||||||
|
|
||||||
|
// load del array (todo)
|
||||||
|
|
||||||
|
// loop to append SDelInfo
|
||||||
|
for (int32_t iMemData = 0; iMemData < taosArrayGetSize(pCHandle->pMemTable->aMemData); iMemData++) {
|
||||||
|
pMemData = (SMemData *)taosArrayGetP(pCHandle->pMemTable->aMemData, iMemData);
|
||||||
|
|
||||||
|
for (SDelOp *pDelOp = pMemData->delOpHead; pDelOp; pDelOp = pDelOp->pNext) {
|
||||||
|
delInfo = (SDelInfo){.suid = pMemData->suid,
|
||||||
|
.uid = pMemData->uid,
|
||||||
|
.version = pDelOp->version,
|
||||||
|
.sKey = pDelOp->sKey,
|
||||||
|
.eKey = pDelOp->eKey};
|
||||||
|
if (taosArrayPush(pCHandle->aDelInfo, &delInfo) == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArraySort(pCHandle->aDelInfo, delInfoCmprFn);
|
||||||
|
|
||||||
|
// write to new file
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitCache(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitImpl(SCommitH *pCHandle) {
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
// commit data
|
||||||
|
code = tsdbCommitData(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit delete
|
||||||
|
code = tsdbCommitDelete(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit cache if need (todo)
|
||||||
|
if (0) {
|
||||||
|
code = tsdbCommitCache(pCHandle);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
@ -216,16 +216,7 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pfs->metaCache = taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
|
||||||
if (pfs->metaCache == NULL) {
|
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
|
||||||
tsdbFreeFS(pfs);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pfs->intxn = false;
|
pfs->intxn = false;
|
||||||
pfs->metaCacheComp = NULL;
|
|
||||||
|
|
||||||
pfs->nstatus = tsdbNewFSStatus(maxFSet);
|
pfs->nstatus = tsdbNewFSStatus(maxFSet);
|
||||||
if (pfs->nstatus == NULL) {
|
if (pfs->nstatus == NULL) {
|
||||||
tsdbFreeFS(pfs);
|
tsdbFreeFS(pfs);
|
||||||
|
|
@ -238,8 +229,6 @@ STsdbFS *tsdbNewFS(const STsdbKeepCfg *pCfg) {
|
||||||
void *tsdbFreeFS(STsdbFS *pfs) {
|
void *tsdbFreeFS(STsdbFS *pfs) {
|
||||||
if (pfs) {
|
if (pfs) {
|
||||||
pfs->nstatus = tsdbFreeFSStatus(pfs->nstatus);
|
pfs->nstatus = tsdbFreeFSStatus(pfs->nstatus);
|
||||||
taosHashCleanup(pfs->metaCache);
|
|
||||||
pfs->metaCache = NULL;
|
|
||||||
pfs->cstatus = tsdbFreeFSStatus(pfs->cstatus);
|
pfs->cstatus = tsdbFreeFSStatus(pfs->cstatus);
|
||||||
taosThreadRwlockDestroy(&(pfs->lock));
|
taosThreadRwlockDestroy(&(pfs->lock));
|
||||||
taosMemoryFree(pfs);
|
taosMemoryFree(pfs);
|
||||||
|
|
@ -963,13 +952,6 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbRestoreCurrent(STsdb *pRepo) {
|
static int tsdbRestoreCurrent(STsdb *pRepo) {
|
||||||
// // Loop to recover mfile
|
|
||||||
// if (tsdbRestoreMeta(pRepo) < 0) {
|
|
||||||
// tsdbError("vgId:%d, failed to restore current since %s", REPO_ID(pRepo), tstrerror(terrno));
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Loop to recover dfile set
|
|
||||||
if (tsdbRestoreDFileSet(pRepo) < 0) {
|
if (tsdbRestoreDFileSet(pRepo) < 0) {
|
||||||
tsdbError("vgId:%d, failed to restore DFileSet since %s", REPO_ID(pRepo), tstrerror(terrno));
|
tsdbError("vgId:%d, failed to restore DFileSet since %s", REPO_ID(pRepo), tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1052,3 +1034,30 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired) {
|
||||||
tsdbCloseDFileSet(&fset);
|
tsdbCloseDFileSet(&fset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tsdbRLockFS(STsdbFS *pFs) {
|
||||||
|
int code = taosThreadRwlockRdlock(&(pFs->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbWLockFS(STsdbFS *pFs) {
|
||||||
|
int code = taosThreadRwlockWrlock(&(pFs->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbUnLockFS(STsdbFS *pFs) {
|
||||||
|
int code = taosThreadRwlockUnlock(&(pFs->lock));
|
||||||
|
if (code != 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(code);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -448,3 +448,136 @@ static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tsdbOpenDFile(SDFile *pDFile, int flags) {
|
||||||
|
ASSERT(!TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
|
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), flags);
|
||||||
|
if (pDFile->pFile == NULL) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbCloseDFile(SDFile *pDFile) {
|
||||||
|
if (TSDB_FILE_OPENED(pDFile)) {
|
||||||
|
taosCloseFile(&pDFile->pFile);
|
||||||
|
TSDB_FILE_SET_CLOSED(pDFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t tsdbSeekDFile(SDFile *pDFile, int64_t offset, int whence) {
|
||||||
|
// ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
|
int64_t loffset = taosLSeekFile(TSDB_FILE_PFILE(pDFile), offset, whence);
|
||||||
|
if (loffset < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return loffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t tsdbWriteDFile(SDFile *pDFile, void *buf, int64_t nbyte) {
|
||||||
|
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
|
int64_t nwrite = taosWriteFile(pDFile->pFile, buf, nbyte);
|
||||||
|
if (nwrite < nbyte) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nwrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbUpdateDFileMagic(SDFile *pDFile, void *pCksm) {
|
||||||
|
pDFile->info.magic = taosCalcChecksum(pDFile->info.magic, (uint8_t *)(pCksm), sizeof(TSCKSUM));
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbAppendDFile(SDFile *pDFile, void *buf, int64_t nbyte, int64_t *offset) {
|
||||||
|
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
|
int64_t toffset;
|
||||||
|
|
||||||
|
if ((toffset = tsdbSeekDFile(pDFile, 0, SEEK_END)) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pDFile->info.size == toffset);
|
||||||
|
|
||||||
|
if (offset) {
|
||||||
|
*offset = toffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbWriteDFile(pDFile, buf, nbyte) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDFile->info.size += nbyte;
|
||||||
|
|
||||||
|
return (int)nbyte;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbRemoveDFile(SDFile *pDFile) { return tfsRemoveFile(TSDB_FILE_F(pDFile)); }
|
||||||
|
|
||||||
|
int64_t tsdbReadDFile(SDFile *pDFile, void *buf, int64_t nbyte) {
|
||||||
|
ASSERT(TSDB_FILE_OPENED(pDFile));
|
||||||
|
|
||||||
|
int64_t nread = taosReadFile(pDFile->pFile, buf, nbyte);
|
||||||
|
if (nread < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nread;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbCopyDFile(SDFile *pSrc, SDFile *pDest) {
|
||||||
|
if (tfsCopyFile(TSDB_FILE_F(pSrc), TSDB_FILE_F(pDest)) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDest->info = pSrc->info;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbCloseDFileSet(SDFileSet *pSet) {
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
tsdbCloseDFile(TSDB_DFILE_IN_SET(pSet, ftype));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbOpenDFileSet(SDFileSet *pSet, int flags) {
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
if (tsdbOpenDFile(TSDB_DFILE_IN_SET(pSet, ftype), flags) < 0) {
|
||||||
|
tsdbCloseDFileSet(pSet);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbRemoveDFileSet(SDFileSet *pSet) {
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
(void)tsdbRemoveDFile(TSDB_DFILE_IN_SET(pSet, ftype));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int tsdbCopyDFileSet(SDFileSet *pSrc, SDFileSet *pDest) {
|
||||||
|
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
|
||||||
|
if (tsdbCopyDFile(TSDB_DFILE_IN_SET(pSrc, ftype), TSDB_DFILE_IN_SET(pDest, ftype)) < 0) {
|
||||||
|
tsdbRemoveDFileSet(pDest);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbGetFidKeyRange(int days, int8_t precision, int fid, TSKEY *minKey, TSKEY *maxKey) {
|
||||||
|
*minKey = fid * days * tsTickPerMin[precision];
|
||||||
|
*maxKey = *minKey + days * tsTickPerMin[precision] - 1;
|
||||||
|
}
|
||||||
|
|
@ -297,8 +297,8 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo
|
||||||
tSkipListPutBatchByIter(pTbData->pData, &blkIter, (iter_next_fn_t)tGetSubmitBlkNext);
|
tSkipListPutBatchByIter(pTbData->pData, &blkIter, (iter_next_fn_t)tGetSubmitBlkNext);
|
||||||
|
|
||||||
#ifdef TD_DEBUG_PRINT_ROW
|
#ifdef TD_DEBUG_PRINT_ROW
|
||||||
printf("!!! %s:%d table %" PRIi64 " has %d rows in skiplist\n\n", __func__, __LINE__, pTbData->uid,
|
printf("!!! %s:%d vgId:%d dir:%s table:%" PRIi64 " has %d rows in skiplist\n\n", __func__, __LINE__,
|
||||||
SL_SIZE(pTbData->pData));
|
TD_VID(pTsdb->pVnode), pTsdb->dir, pTbData->uid, SL_SIZE(pTbData->pData));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set statistics
|
// Set statistics
|
||||||
|
|
|
||||||
|
|
@ -15,42 +15,15 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
typedef struct SMemData SMemData;
|
|
||||||
typedef struct SMemSkipList SMemSkipList;
|
|
||||||
typedef struct SMemSkipListNode SMemSkipListNode;
|
|
||||||
|
|
||||||
struct SMemSkipListNode {
|
struct SMemSkipListNode {
|
||||||
int8_t level;
|
int8_t level;
|
||||||
SMemSkipListNode *forwards[0];
|
SMemSkipListNode *forwards[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemSkipList {
|
typedef struct {
|
||||||
uint32_t seed;
|
|
||||||
int32_t size;
|
|
||||||
int8_t maxLevel;
|
|
||||||
int8_t level;
|
|
||||||
SMemSkipListNode *pHead;
|
|
||||||
SMemSkipListNode *pTail;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SMemData {
|
|
||||||
tb_uid_t suid;
|
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
TSDBKEY minKey;
|
STSchema *pTSchema;
|
||||||
TSDBKEY maxKey;
|
} SSkmInfo;
|
||||||
SDelOp *delOpHead;
|
|
||||||
SDelOp *delOpTail;
|
|
||||||
SMemSkipList sl;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SMemTable {
|
|
||||||
STsdb *pTsdb;
|
|
||||||
int32_t nRef;
|
|
||||||
TSDBKEY minKey;
|
|
||||||
TSDBKEY maxKey;
|
|
||||||
int64_t nRows;
|
|
||||||
SArray *pArray; // SArray<SMemData>
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SL_MAX_LEVEL 5
|
#define SL_MAX_LEVEL 5
|
||||||
|
|
||||||
|
|
@ -59,14 +32,17 @@ struct SMemTable {
|
||||||
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
|
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
|
||||||
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
|
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
|
||||||
|
|
||||||
|
#define SL_MOVE_BACKWARD 0x1
|
||||||
|
#define SL_MOVE_FROM_POS 0x2
|
||||||
|
|
||||||
static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData);
|
static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData);
|
||||||
static int memDataPCmprFn(const void *p1, const void *p2);
|
static int memDataPCmprFn(const void *p1, const void *p2);
|
||||||
static int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
|
static int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
|
||||||
static int32_t tGetTSDBRow(uint8_t *p, TSDBROW *pRow);
|
static int32_t tGetTSDBRow(uint8_t *p, TSDBROW *pRow);
|
||||||
static int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl);
|
static int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl);
|
||||||
static void memDataMovePos(SMemData *pMemData, TSDBROW *pRow, int8_t isForward, SMemSkipListNode **pos);
|
static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, SMemData *pMemData, int64_t version,
|
||||||
static int32_t memDataPutRow(SVBufPool *pPool, SMemData *pMemData, TSDBROW *pRow, int8_t isForward,
|
SVSubmitBlk *pSubmitBlk);
|
||||||
SMemSkipListNode **pos);
|
static void memDataMovePosTo(SMemData *pMemData, SMemSkipListNode **pos, TSDBKEY *pKey, int32_t flags);
|
||||||
|
|
||||||
// SMemTable ==============================================
|
// SMemTable ==============================================
|
||||||
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable) {
|
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
|
|
@ -83,8 +59,9 @@ int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable) {
|
||||||
pMemTable->minKey = (TSDBKEY){.version = INT64_MAX, .ts = TSKEY_MAX};
|
pMemTable->minKey = (TSDBKEY){.version = INT64_MAX, .ts = TSKEY_MAX};
|
||||||
pMemTable->maxKey = (TSDBKEY){.version = -1, .ts = TSKEY_MIN};
|
pMemTable->maxKey = (TSDBKEY){.version = -1, .ts = TSKEY_MIN};
|
||||||
pMemTable->nRows = 0;
|
pMemTable->nRows = 0;
|
||||||
pMemTable->pArray = taosArrayInit(512, sizeof(SMemData *));
|
pMemTable->nDelOp = 0;
|
||||||
if (pMemTable->pArray == NULL) {
|
pMemTable->aMemData = taosArrayInit(512, sizeof(SMemData *));
|
||||||
|
if (pMemTable->aMemData == NULL) {
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
@ -99,7 +76,7 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsdbMemTableDestroy2(SMemTable *pMemTable) {
|
void tsdbMemTableDestroy2(SMemTable *pMemTable) {
|
||||||
taosArrayDestroyEx(pMemTable->pArray, NULL /*TODO*/);
|
taosArrayDestroyEx(pMemTable->aMemData, NULL /*TODO*/);
|
||||||
taosMemoryFree(pMemTable);
|
taosMemoryFree(pMemTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,30 +100,11 @@ int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmit
|
||||||
}
|
}
|
||||||
|
|
||||||
// do insert
|
// do insert
|
||||||
int32_t nt;
|
code = tsdbInsertTableDataImpl(pMemTable, pMemData, version, pSubmitBlk);
|
||||||
int32_t n = 0;
|
|
||||||
uint8_t *p = pSubmitBlk->pData;
|
|
||||||
int32_t nRow = 0;
|
|
||||||
SMemSkipListNode *pos[SL_MAX_LEVEL] = {0};
|
|
||||||
|
|
||||||
for (int8_t iLevel = 0; iLevel < SL_MAX_LEVEL; iLevel++) {
|
|
||||||
pos[iLevel] = pMemData->sl.pTail;
|
|
||||||
}
|
|
||||||
while (n < pSubmitBlk->nData) {
|
|
||||||
nt = tGetTSRow(p + n, &row.tsRow);
|
|
||||||
n += nt;
|
|
||||||
|
|
||||||
ASSERT(n <= pSubmitBlk->nData);
|
|
||||||
|
|
||||||
memDataMovePos(pMemData, &row, nRow ? 1 : 0, pos);
|
|
||||||
code = memDataPutRow(pTsdb->pVnode->inUse, pMemData, &row, nRow ? 1 : 0, pos);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nRow++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
@ -192,6 +150,8 @@ int32_t tsdbDeleteTableData2(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_ui
|
||||||
// update the state of pMemTable, pMemData, last and lastrow (todo)
|
// update the state of pMemTable, pMemData, last and lastrow (todo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMemTable->nDelOp++;
|
||||||
|
|
||||||
tsdbDebug("vgId:%d, delete data from table suid:%" PRId64 " uid:%" PRId64 " sKey:%" PRId64 " eKey:%" PRId64
|
tsdbDebug("vgId:%d, delete data from table suid:%" PRId64 " uid:%" PRId64 " sKey:%" PRId64 " eKey:%" PRId64
|
||||||
" since %s",
|
" since %s",
|
||||||
TD_VID(pTsdb->pVnode), suid, uid, sKey, eKey, tstrerror(code));
|
TD_VID(pTsdb->pVnode), suid, uid, sKey, eKey, tstrerror(code));
|
||||||
|
|
@ -204,6 +164,92 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tsdbMemDataIterOpen(SMemData *pMemData, TSDBKEY *pKey, int8_t backward, SMemDataIter *pIter) {
|
||||||
|
SMemSkipListNode *pos[SL_MAX_LEVEL];
|
||||||
|
|
||||||
|
pIter->pMemData = pMemData;
|
||||||
|
pIter->backward = backward;
|
||||||
|
pIter->pRow = NULL;
|
||||||
|
if (pKey == NULL) {
|
||||||
|
// create from head or tail
|
||||||
|
if (backward) {
|
||||||
|
pIter->pNode = SL_NODE_BACKWARD(pMemData->sl.pTail, 0);
|
||||||
|
} else {
|
||||||
|
pIter->pNode = SL_NODE_FORWARD(pMemData->sl.pHead, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// create from a key
|
||||||
|
if (backward) {
|
||||||
|
memDataMovePosTo(pMemData, pos, pKey, SL_MOVE_BACKWARD);
|
||||||
|
pIter->pNode = SL_NODE_BACKWARD(pos[0], 0);
|
||||||
|
} else {
|
||||||
|
memDataMovePosTo(pMemData, pos, pKey, 0);
|
||||||
|
pIter->pNode = SL_NODE_FORWARD(pos[0], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tsdbMemDataIterNext(SMemDataIter *pIter) {
|
||||||
|
SMemSkipListNode *pHead = pIter->pMemData->sl.pHead;
|
||||||
|
SMemSkipListNode *pTail = pIter->pMemData->sl.pTail;
|
||||||
|
|
||||||
|
pIter->pRow = NULL;
|
||||||
|
if (pIter->backward) {
|
||||||
|
ASSERT(pIter->pNode != pTail);
|
||||||
|
|
||||||
|
if (pIter->pNode == pHead) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter->pNode = SL_NODE_BACKWARD(pIter->pNode, 0);
|
||||||
|
if (pIter->pNode == pHead) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT(pIter->pNode != pHead);
|
||||||
|
|
||||||
|
if (pIter->pNode == pTail) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter->pNode = SL_NODE_FORWARD(pIter->pNode, 0);
|
||||||
|
if (pIter->pNode == pTail) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tsdbMemDataIterGet(SMemDataIter *pIter, TSDBROW **ppRow) {
|
||||||
|
if (pIter->pRow) {
|
||||||
|
*ppRow = pIter->pRow;
|
||||||
|
} else {
|
||||||
|
SMemSkipListNode *pHead = pIter->pMemData->sl.pHead;
|
||||||
|
SMemSkipListNode *pTail = pIter->pMemData->sl.pTail;
|
||||||
|
|
||||||
|
if (pIter->backward) {
|
||||||
|
ASSERT(pIter->pNode != pTail);
|
||||||
|
|
||||||
|
if (pIter->pNode == pHead) {
|
||||||
|
*ppRow = NULL;
|
||||||
|
} else {
|
||||||
|
tGetTSDBRow((uint8_t *)SL_NODE_DATA(pIter->pNode), &pIter->row);
|
||||||
|
*ppRow = &pIter->row;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ASSERT(pIter->pNode != pHead);
|
||||||
|
|
||||||
|
if (pIter->pNode == pTail) {
|
||||||
|
*ppRow = NULL;
|
||||||
|
} else {
|
||||||
|
tGetTSDBRow((uint8_t *)SL_NODE_DATA(pIter->pNode), &pIter->row);
|
||||||
|
*ppRow = &pIter->row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData) {
|
static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t uid, SMemData **ppMemData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t idx = 0;
|
int32_t idx = 0;
|
||||||
|
|
@ -213,9 +259,9 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
|
||||||
int8_t maxLevel = pMemTable->pTsdb->pVnode->config.tsdbCfg.slLevel;
|
int8_t maxLevel = pMemTable->pTsdb->pVnode->config.tsdbCfg.slLevel;
|
||||||
|
|
||||||
// get
|
// get
|
||||||
idx = taosArraySearchIdx(pMemTable->pArray, &pMemDataT, memDataPCmprFn, TD_GE);
|
idx = taosArraySearchIdx(pMemTable->aMemData, &pMemDataT, memDataPCmprFn, TD_GE);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
pMemData = (SMemData *)taosArrayGet(pMemTable->pArray, idx);
|
pMemData = (SMemData *)taosArrayGet(pMemTable->aMemData, idx);
|
||||||
if (memDataPCmprFn(&pMemDataT, &pMemData) == 0) goto _exit;
|
if (memDataPCmprFn(&pMemDataT, &pMemData) == 0) goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,7 +293,7 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx < 0) idx = 0;
|
if (idx < 0) idx = 0;
|
||||||
if (taosArrayInsert(pMemTable->pArray, idx, &pMemData) == NULL) {
|
if (taosArrayInsert(pMemTable->aMemData, idx, &pMemData) == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
@ -310,28 +356,62 @@ static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memDataMovePos(SMemData *pMemData, TSDBROW *pRow, int8_t isForward, SMemSkipListNode **pos) {
|
static void memDataMovePosTo(SMemData *pMemData, SMemSkipListNode **pos, TSDBKEY *pKey, int32_t flags) {
|
||||||
TSDBKEY *pKey;
|
SMemSkipListNode *px;
|
||||||
|
SMemSkipListNode *pn;
|
||||||
|
TSDBKEY *pTKey;
|
||||||
int c;
|
int c;
|
||||||
|
int backward = flags & SL_MOVE_BACKWARD;
|
||||||
|
int fromPos = flags & SL_MOVE_FROM_POS;
|
||||||
|
|
||||||
if (isForward) {
|
if (backward) {
|
||||||
// TODO
|
px = pMemData->sl.pTail;
|
||||||
} else {
|
|
||||||
SMemSkipListNode *px = pMemData->sl.pTail;
|
|
||||||
|
|
||||||
for (int8_t iLevel = pMemData->sl.maxLevel - 1; iLevel >= 0; iLevel--) {
|
for (int8_t iLevel = pMemData->sl.maxLevel - 1; iLevel >= pMemData->sl.level; iLevel--) {
|
||||||
if (iLevel < pMemData->sl.level) {
|
pos[iLevel] = px;
|
||||||
SMemSkipListNode *p = SL_NODE_BACKWARD(px, iLevel);
|
}
|
||||||
|
|
||||||
while (p != pMemData->sl.pHead) {
|
if (pMemData->sl.level) {
|
||||||
pKey = (TSDBKEY *)SL_NODE_DATA(p);
|
if (fromPos) px = pos[pMemData->sl.level - 1];
|
||||||
|
|
||||||
c = tsdbKeyCmprFn(pKey, pRow);
|
for (int8_t iLevel = pMemData->sl.level - 1; iLevel >= 0; iLevel--) {
|
||||||
|
pn = SL_NODE_BACKWARD(px, iLevel);
|
||||||
|
while (pn != pMemData->sl.pHead) {
|
||||||
|
pTKey = (TSDBKEY *)SL_NODE_DATA(pn);
|
||||||
|
|
||||||
|
c = tsdbKeyCmprFn(pTKey, pKey);
|
||||||
if (c <= 0) {
|
if (c <= 0) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
px = p;
|
px = pn;
|
||||||
p = SL_NODE_BACKWARD(px, iLevel);
|
pn = SL_NODE_BACKWARD(px, iLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos[iLevel] = px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
px = pMemData->sl.pHead;
|
||||||
|
|
||||||
|
for (int8_t iLevel = pMemData->sl.maxLevel - 1; iLevel >= pMemData->sl.level; iLevel--) {
|
||||||
|
pos[iLevel] = px;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMemData->sl.level) {
|
||||||
|
if (fromPos) px = pos[pMemData->sl.level - 1];
|
||||||
|
|
||||||
|
for (int8_t iLevel = pMemData->sl.level - 1; iLevel >= 0; iLevel--) {
|
||||||
|
pn = SL_NODE_FORWARD(px, iLevel);
|
||||||
|
while (pn != pMemData->sl.pHead) {
|
||||||
|
pTKey = (TSDBKEY *)SL_NODE_DATA(pn);
|
||||||
|
|
||||||
|
c = tsdbKeyCmprFn(pTKey, pKey);
|
||||||
|
if (c >= 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
px = pn;
|
||||||
|
pn = SL_NODE_FORWARD(px, iLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,56 +421,115 @@ static void memDataMovePos(SMemData *pMemData, TSDBROW *pRow, int8_t isForward,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void memMovePosFrom(SMemData *pMemData, SMemSkipListNode *pNode, TSDBROW *pRow, int8_t isForward,
|
static int32_t memDataDoPut(SMemTable *pMemTable, SMemData *pMemData, SMemSkipListNode **pos, TSDBROW *pRow,
|
||||||
SMemSkipListNode **pos) {
|
int8_t forward) {
|
||||||
SMemSkipListNode *px = pNode;
|
|
||||||
TSDBKEY *pKey;
|
|
||||||
SMemSkipListNode *p;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (isForward) {
|
|
||||||
} else {
|
|
||||||
ASSERT(pNode != pMemData->sl.pHead);
|
|
||||||
|
|
||||||
for (int8_t iLevel = pMemData->sl.maxLevel - 1; iLevel >= 0; iLevel--) {
|
|
||||||
p = SL_NODE_BACKWARD(px, iLevel);
|
|
||||||
while (p != pMemData->sl.pHead) {
|
|
||||||
pKey = (TSDBKEY *)SL_NODE_DATA(p);
|
|
||||||
|
|
||||||
c = tsdbKeyCmprFn(pKey, pRow);
|
|
||||||
if (c <= 0) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
px = p;
|
|
||||||
p = SL_NODE_BACKWARD(px, iLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pos[iLevel] = px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t memDataPutRow(SVBufPool *pPool, SMemData *pMemData, TSDBROW *pRow, int8_t isForward,
|
|
||||||
SMemSkipListNode **pos) {
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int8_t level;
|
int8_t level;
|
||||||
SMemSkipListNode *pNode;
|
SMemSkipListNode *pNode;
|
||||||
|
SVBufPool *pPool = pMemTable->pTsdb->pVnode->inUse;
|
||||||
|
|
||||||
|
// node
|
||||||
level = tsdbMemSkipListRandLevel(&pMemData->sl);
|
level = tsdbMemSkipListRandLevel(&pMemData->sl);
|
||||||
pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level) + tPutTSDBRow(NULL, pRow));
|
pNode = (SMemSkipListNode *)vnodeBufPoolMalloc(pPool, SL_NODE_SIZE(level) + tPutTSDBRow(NULL, pRow));
|
||||||
if (pNode == NULL) {
|
if (pNode == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
pNode->level = level;
|
||||||
|
for (int8_t iLevel = 0; iLevel < level; iLevel++) {
|
||||||
|
SL_NODE_FORWARD(pNode, iLevel) = NULL;
|
||||||
|
SL_NODE_BACKWARD(pNode, iLevel) = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// do the read put
|
tPutTSDBRow((uint8_t *)SL_NODE_DATA(pNode), pRow);
|
||||||
if (isForward) {
|
|
||||||
// TODO
|
// put
|
||||||
|
for (int8_t iLevel = 0; iLevel < pNode->level; iLevel++) {
|
||||||
|
SMemSkipListNode *px = pos[iLevel];
|
||||||
|
|
||||||
|
if (forward) {
|
||||||
|
SMemSkipListNode *pNext = SL_NODE_FORWARD(px, iLevel);
|
||||||
|
|
||||||
|
SL_NODE_FORWARD(pNode, iLevel) = pNext;
|
||||||
|
SL_NODE_BACKWARD(pNode, iLevel) = px;
|
||||||
|
|
||||||
|
SL_NODE_BACKWARD(pNext, iLevel) = pNode;
|
||||||
|
SL_NODE_FORWARD(px, iLevel) = pNode;
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
SMemSkipListNode *pPrev = SL_NODE_BACKWARD(px, iLevel);
|
||||||
|
|
||||||
|
SL_NODE_FORWARD(pNode, iLevel) = px;
|
||||||
|
SL_NODE_BACKWARD(pNode, iLevel) = pPrev;
|
||||||
|
|
||||||
|
SL_NODE_FORWARD(pPrev, iLevel) = pNode;
|
||||||
|
SL_NODE_BACKWARD(px, iLevel) = pNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pMemData->sl.size++;
|
||||||
|
if (pMemData->sl.level < pNode->level) {
|
||||||
|
pMemData->sl.level = pNode->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, SMemData *pMemData, int64_t version,
|
||||||
|
SVSubmitBlk *pSubmitBlk) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t n = 0;
|
||||||
|
uint8_t *p = pSubmitBlk->pData;
|
||||||
|
int32_t nRow = 0;
|
||||||
|
TSDBROW row = {.version = version};
|
||||||
|
|
||||||
|
SMemSkipListNode *pos[SL_MAX_LEVEL];
|
||||||
|
|
||||||
|
ASSERT(pSubmitBlk->nData);
|
||||||
|
|
||||||
|
// backward put first data
|
||||||
|
n += tGetTSRow(p + n, &row.tsRow);
|
||||||
|
ASSERT(n <= pSubmitBlk->nData);
|
||||||
|
|
||||||
|
memDataMovePosTo(pMemData, pos, &(TSDBKEY){.version = version, .ts = row.tsRow.ts}, SL_MOVE_BACKWARD);
|
||||||
|
code = memDataDoPut(pMemTable, pMemData, pos, &row, 0);
|
||||||
|
if (code) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
nRow++;
|
||||||
|
|
||||||
|
if (tsdbKeyCmprFn((TSDBKEY *)&row, &pMemData->minKey) < 0) {
|
||||||
|
pMemData->minKey = *(TSDBKEY *)&row;
|
||||||
|
}
|
||||||
|
if (tsdbKeyCmprFn((TSDBKEY *)&row, &pMemTable->minKey) < 0) {
|
||||||
|
pMemTable->minKey = *(TSDBKEY *)&row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// forward put rest
|
||||||
|
for (int8_t iLevel = 0; iLevel < pMemData->sl.maxLevel; iLevel++) {
|
||||||
|
pos[iLevel] = SL_NODE_BACKWARD(pos[iLevel], iLevel);
|
||||||
|
}
|
||||||
|
while (n < pSubmitBlk->nData) {
|
||||||
|
n += tGetTSRow(p + n, &row.tsRow);
|
||||||
|
ASSERT(n <= pSubmitBlk->nData);
|
||||||
|
|
||||||
|
memDataMovePosTo(pMemData, pos, &(TSDBKEY){.version = version, .ts = row.tsRow.ts}, SL_MOVE_FROM_POS);
|
||||||
|
code = memDataDoPut(pMemTable, pMemData, pos, &row, 1);
|
||||||
|
if (code) {
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
nRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsdbKeyCmprFn((TSDBKEY *)&row, &pMemData->maxKey) > 0) {
|
||||||
|
pMemData->maxKey = *(TSDBKEY *)&row;
|
||||||
|
}
|
||||||
|
if (tsdbKeyCmprFn((TSDBKEY *)&row, &pMemTable->maxKey) > 0) {
|
||||||
|
pMemTable->maxKey = *(TSDBKEY *)&row;
|
||||||
|
}
|
||||||
|
pMemTable->nRows += nRow;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns)))
|
#define QH_GET_NUM_OF_COLS(handle) ((size_t)(taosArrayGetSize((handle)->pColumns)))
|
||||||
|
|
||||||
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
||||||
((SDataBlockInfo){.window = {.skey = (_block)->keyFirst, .ekey = (_block)->keyLast}, \
|
((SDataBlockInfo){.window = {.skey = (_block)->minKey.ts, .ekey = (_block)->maxKey.ts}, \
|
||||||
.numOfCols = (_block)->numOfCols, \
|
.numOfCols = (_block)->numOfCols, \
|
||||||
.rows = (_block)->numOfRows, \
|
.rows = (_block)->numOfRows, \
|
||||||
.uid = (_checkInfo)->tableId})
|
.uid = (_checkInfo)->tableId})
|
||||||
|
|
@ -1105,12 +1105,12 @@ static int32_t binarySearchForBlock(SBlock* pBlock, int32_t numOfBlocks, TSKEY s
|
||||||
|
|
||||||
if (numOfBlocks == 1) break;
|
if (numOfBlocks == 1) break;
|
||||||
|
|
||||||
if (skey > pBlock[midSlot].keyLast) {
|
if (skey > pBlock[midSlot].maxKey.ts) {
|
||||||
if (numOfBlocks == 2) break;
|
if (numOfBlocks == 2) break;
|
||||||
if ((order == TSDB_ORDER_DESC) && (skey < pBlock[midSlot + 1].keyFirst)) break;
|
if ((order == TSDB_ORDER_DESC) && (skey < pBlock[midSlot + 1].minKey.ts)) break;
|
||||||
firstSlot = midSlot + 1;
|
firstSlot = midSlot + 1;
|
||||||
} else if (skey < pBlock[midSlot].keyFirst) {
|
} else if (skey < pBlock[midSlot].minKey.ts) {
|
||||||
if ((order == TSDB_ORDER_ASC) && (skey > pBlock[midSlot - 1].keyLast)) break;
|
if ((order == TSDB_ORDER_ASC) && (skey > pBlock[midSlot - 1].maxKey.ts)) break;
|
||||||
lastSlot = midSlot - 1;
|
lastSlot = midSlot - 1;
|
||||||
} else {
|
} else {
|
||||||
break; // got the slot
|
break; // got the slot
|
||||||
|
|
@ -1177,12 +1177,12 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in
|
||||||
int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC);
|
int32_t start = binarySearchForBlock(pCompInfo->blocks, compIndex->numOfBlocks, s, TSDB_ORDER_ASC);
|
||||||
int32_t end = start;
|
int32_t end = start;
|
||||||
|
|
||||||
if (s > pCompInfo->blocks[start].keyLast) {
|
if (s > pCompInfo->blocks[start].maxKey.ts) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo speedup the procedure of located end block
|
// todo speedup the procedure of located end block
|
||||||
while (end < (int32_t)compIndex->numOfBlocks && (pCompInfo->blocks[end].keyFirst <= e)) {
|
while (end < (int32_t)compIndex->numOfBlocks && (pCompInfo->blocks[end].minKey.ts <= e)) {
|
||||||
end += 1;
|
end += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1275,7 +1275,7 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
|
||||||
pBlock->numOfRows = pCols->numOfRows;
|
pBlock->numOfRows = pCols->numOfRows;
|
||||||
|
|
||||||
// Convert from TKEY to TSKEY for primary timestamp column if current block has timestamp before 1970-01-01T00:00:00Z
|
// Convert from TKEY to TSKEY for primary timestamp column if current block has timestamp before 1970-01-01T00:00:00Z
|
||||||
if (pBlock->keyFirst < 0 && colIds[0] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (pBlock->minKey.ts < 0 && colIds[0] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
int64_t* src = pCols->cols[0].pData;
|
int64_t* src = pCols->cols[0].pData;
|
||||||
for (int32_t i = 0; i < pBlock->numOfRows; ++i) {
|
for (int32_t i = 0; i < pBlock->numOfRows; ++i) {
|
||||||
src[i] = tdGetKey(src[i]);
|
src[i] = tdGetKey(src[i]);
|
||||||
|
|
@ -1287,7 +1287,7 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
|
||||||
|
|
||||||
tsdbDebug("%p load file block into buffer, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%" PRId64
|
tsdbDebug("%p load file block into buffer, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%" PRId64
|
||||||
" us, %s",
|
" us, %s",
|
||||||
pTsdbReadHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, elapsedTime,
|
pTsdbReadHandle, slotIndex, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->numOfRows, elapsedTime,
|
||||||
pTsdbReadHandle->idStr);
|
pTsdbReadHandle->idStr);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
|
@ -1295,7 +1295,8 @@ _error:
|
||||||
pBlock->numOfRows = 0;
|
pBlock->numOfRows = 0;
|
||||||
|
|
||||||
tsdbError("%p error occurs in loading file block, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, %s",
|
tsdbError("%p error occurs in loading file block, index:%d, brange:%" PRId64 "-%" PRId64 ", rows:%d, %s",
|
||||||
pTsdbReadHandle, slotIndex, pBlock->keyFirst, pBlock->keyLast, pBlock->numOfRows, pTsdbReadHandle->idStr);
|
pTsdbReadHandle, slotIndex, pBlock->minKey.ts, pBlock->maxKey.ts, pBlock->numOfRows,
|
||||||
|
pTsdbReadHandle->idStr);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1423,7 +1424,7 @@ static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBloc
|
||||||
|
|
||||||
if (asc) {
|
if (asc) {
|
||||||
// query ended in/started from current block
|
// query ended in/started from current block
|
||||||
if (pTsdbReadHandle->window.ekey < pBlock->keyLast || pCheckInfo->lastKey > pBlock->keyFirst) {
|
if (pTsdbReadHandle->window.ekey < pBlock->maxKey.ts || pCheckInfo->lastKey > pBlock->minKey.ts) {
|
||||||
if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) {
|
if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) {
|
||||||
*exists = false;
|
*exists = false;
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -1432,35 +1433,35 @@ static int32_t loadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBloc
|
||||||
SDataCols* pTSCol = pTsdbReadHandle->rhelper.pDCols[0];
|
SDataCols* pTSCol = pTsdbReadHandle->rhelper.pDCols[0];
|
||||||
assert(pTSCol->cols->type == TSDB_DATA_TYPE_TIMESTAMP && pTSCol->numOfRows == pBlock->numOfRows);
|
assert(pTSCol->cols->type == TSDB_DATA_TYPE_TIMESTAMP && pTSCol->numOfRows == pBlock->numOfRows);
|
||||||
|
|
||||||
if (pCheckInfo->lastKey > pBlock->keyFirst) {
|
if (pCheckInfo->lastKey > pBlock->minKey.ts) {
|
||||||
cur->pos =
|
cur->pos =
|
||||||
binarySearchForKey(pTSCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order);
|
binarySearchForKey(pTSCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order);
|
||||||
} else {
|
} else {
|
||||||
cur->pos = 0;
|
cur->pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pCheckInfo->lastKey <= pBlock->keyLast);
|
assert(pCheckInfo->lastKey <= pBlock->maxKey.ts);
|
||||||
doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock);
|
doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock);
|
||||||
} else { // the whole block is loaded in to buffer
|
} else { // the whole block is loaded in to buffer
|
||||||
cur->pos = asc ? 0 : (pBlock->numOfRows - 1);
|
cur->pos = asc ? 0 : (pBlock->numOfRows - 1);
|
||||||
code = handleDataMergeIfNeeded(pTsdbReadHandle, pBlock, pCheckInfo);
|
code = handleDataMergeIfNeeded(pTsdbReadHandle, pBlock, pCheckInfo);
|
||||||
}
|
}
|
||||||
} else { // desc order, query ended in current block
|
} else { // desc order, query ended in current block
|
||||||
if (pTsdbReadHandle->window.ekey > pBlock->keyFirst || pCheckInfo->lastKey < pBlock->keyLast) {
|
if (pTsdbReadHandle->window.ekey > pBlock->minKey.ts || pCheckInfo->lastKey < pBlock->maxKey.ts) {
|
||||||
if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) {
|
if ((code = doLoadFileDataBlock(pTsdbReadHandle, pBlock, pCheckInfo, cur->slot)) != TSDB_CODE_SUCCESS) {
|
||||||
*exists = false;
|
*exists = false;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataCols* pTsCol = pTsdbReadHandle->rhelper.pDCols[0];
|
SDataCols* pTsCol = pTsdbReadHandle->rhelper.pDCols[0];
|
||||||
if (pCheckInfo->lastKey < pBlock->keyLast) {
|
if (pCheckInfo->lastKey < pBlock->maxKey.ts) {
|
||||||
cur->pos =
|
cur->pos =
|
||||||
binarySearchForKey(pTsCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order);
|
binarySearchForKey(pTsCol->cols[0].pData, pBlock->numOfRows, pCheckInfo->lastKey, pTsdbReadHandle->order);
|
||||||
} else {
|
} else {
|
||||||
cur->pos = pBlock->numOfRows - 1;
|
cur->pos = pBlock->numOfRows - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pCheckInfo->lastKey >= pBlock->keyFirst);
|
assert(pCheckInfo->lastKey >= pBlock->minKey.ts);
|
||||||
doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock);
|
doMergeTwoLevelData(pTsdbReadHandle, pCheckInfo, pBlock);
|
||||||
} else {
|
} else {
|
||||||
cur->pos = asc ? 0 : (pBlock->numOfRows - 1);
|
cur->pos = asc ? 0 : (pBlock->numOfRows - 1);
|
||||||
|
|
@ -1661,7 +1662,11 @@ static int32_t mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capa
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TD_DEBUG_PRINT_ROW
|
#ifdef TD_DEBUG_PRINT_ROW
|
||||||
tdSRowPrint(row1, pSchema1, __func__);
|
char flags[70] = {0};
|
||||||
|
STsdb* pTsdb = pTsdbReadHandle->rhelper.pRepo;
|
||||||
|
snprintf(flags, 70, "%s:%d vgId:%d dir:%s row1%s=NULL,row2%s=NULL", __func__, __LINE__, TD_VID(pTsdb->pVnode),
|
||||||
|
pTsdb->dir, row1 ? "!" : "", row2 ? "!" : "");
|
||||||
|
tdSRowPrint(row1, pSchema1, flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (isRow1DataRow) {
|
if (isRow1DataRow) {
|
||||||
|
|
@ -1981,8 +1986,8 @@ static void doMergeTwoLevelData(STsdbReadHandle* pTsdbReadHandle, STableCheckInf
|
||||||
cur->pos >= 0 && cur->pos < pBlock->numOfRows);
|
cur->pos >= 0 && cur->pos < pBlock->numOfRows);
|
||||||
// Even Multi-Version supported, the records with duplicated TSKEY would be merged inside of tsdbLoadData interface.
|
// Even Multi-Version supported, the records with duplicated TSKEY would be merged inside of tsdbLoadData interface.
|
||||||
TSKEY* tsArray = pCols->cols[0].pData;
|
TSKEY* tsArray = pCols->cols[0].pData;
|
||||||
assert(pCols->numOfRows == pBlock->numOfRows && tsArray[0] == pBlock->keyFirst &&
|
assert(pCols->numOfRows == pBlock->numOfRows && tsArray[0] == pBlock->minKey.ts &&
|
||||||
tsArray[pBlock->numOfRows - 1] == pBlock->keyLast);
|
tsArray[pBlock->numOfRows - 1] == pBlock->maxKey.ts);
|
||||||
|
|
||||||
bool ascScan = ASCENDING_TRAVERSE(pTsdbReadHandle->order);
|
bool ascScan = ASCENDING_TRAVERSE(pTsdbReadHandle->order);
|
||||||
int32_t step = ascScan ? 1 : -1;
|
int32_t step = ascScan ? 1 : -1;
|
||||||
|
|
@ -2829,6 +2834,12 @@ void* tsdbGetIdx(SMeta* pMeta) {
|
||||||
}
|
}
|
||||||
return metaGetIdx(pMeta);
|
return metaGetIdx(pMeta);
|
||||||
}
|
}
|
||||||
|
void* tsdbGetIvtIdx(SMeta* pMeta) {
|
||||||
|
if (pMeta == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return metaGetIvtIdx(pMeta);
|
||||||
|
}
|
||||||
int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
|
int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
|
||||||
SMCtbCursor* pCur = metaOpenCtbCursor(pMeta, uid);
|
SMCtbCursor* pCur = metaOpenCtbCursor(pMeta, uid);
|
||||||
|
|
||||||
|
|
@ -3576,8 +3587,8 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
|
||||||
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
assert(pPrimaryColStatis->colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||||
|
|
||||||
pPrimaryColStatis->numOfNull = 0;
|
pPrimaryColStatis->numOfNull = 0;
|
||||||
pPrimaryColStatis->min = pBlockInfo->compBlock->keyFirst;
|
pPrimaryColStatis->min = pBlockInfo->compBlock->minKey.ts;
|
||||||
pPrimaryColStatis->max = pBlockInfo->compBlock->keyLast;
|
pPrimaryColStatis->max = pBlockInfo->compBlock->maxKey.ts;
|
||||||
pHandle->suppInfo.plist[0] = &pHandle->suppInfo.pstatis[0];
|
pHandle->suppInfo.plist[0] = &pHandle->suppInfo.pstatis[0];
|
||||||
|
|
||||||
// update the number of NULL data rows
|
// update the number of NULL data rows
|
||||||
|
|
|
||||||
|
|
@ -339,8 +339,8 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pReadh->pDCols[0]->numOfRows <= pBlock->numOfRows);
|
ASSERT(pReadh->pDCols[0]->numOfRows <= pBlock->numOfRows);
|
||||||
ASSERT(dataColsKeyFirst(pReadh->pDCols[0]) == pBlock->keyFirst);
|
ASSERT(dataColsKeyFirst(pReadh->pDCols[0]) == pBlock->minKey.ts);
|
||||||
ASSERT(dataColsKeyLast(pReadh->pDCols[0]) == pBlock->keyLast);
|
ASSERT(dataColsKeyLast(pReadh->pDCols[0]) == pBlock->maxKey.ts);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -457,8 +457,8 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(pReadh->pDCols[0]->numOfRows <= pBlock->numOfRows);
|
ASSERT(pReadh->pDCols[0]->numOfRows <= pBlock->numOfRows);
|
||||||
ASSERT(dataColsKeyFirst(pReadh->pDCols[0]) == pBlock->keyFirst);
|
ASSERT(dataColsKeyFirst(pReadh->pDCols[0]) == pBlock->minKey.ts);
|
||||||
ASSERT(dataColsKeyLast(pReadh->pDCols[0]) == pBlock->keyLast);
|
ASSERT(dataColsKeyLast(pReadh->pDCols[0]) == pBlock->maxKey.ts);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -559,7 +559,7 @@ int tsdbEncodeSBlockIdx(void **buf, SBlockIdx *pIdx) {
|
||||||
tlen += taosEncodeFixedU8(buf, pIdx->hasLast);
|
tlen += taosEncodeFixedU8(buf, pIdx->hasLast);
|
||||||
tlen += taosEncodeVariantU32(buf, pIdx->numOfBlocks);
|
tlen += taosEncodeVariantU32(buf, pIdx->numOfBlocks);
|
||||||
tlen += taosEncodeFixedU64(buf, pIdx->uid);
|
tlen += taosEncodeFixedU64(buf, pIdx->uid);
|
||||||
tlen += taosEncodeFixedU64(buf, pIdx->maxKey);
|
tlen += taosEncodeFixedU64(buf, pIdx->maxKey.ts);
|
||||||
|
|
||||||
return tlen;
|
return tlen;
|
||||||
}
|
}
|
||||||
|
|
@ -579,7 +579,7 @@ void *tsdbDecodeSBlockIdx(void *buf, SBlockIdx *pIdx) {
|
||||||
if ((buf = taosDecodeFixedU64(buf, &value)) == NULL) return NULL;
|
if ((buf = taosDecodeFixedU64(buf, &value)) == NULL) return NULL;
|
||||||
pIdx->uid = (int64_t)value;
|
pIdx->uid = (int64_t)value;
|
||||||
if ((buf = taosDecodeFixedU64(buf, &value)) == NULL) return NULL;
|
if ((buf = taosDecodeFixedU64(buf, &value)) == NULL) return NULL;
|
||||||
pIdx->maxKey = (TSKEY)value;
|
pIdx->maxKey.ts = (TSKEY)value;
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
@ -726,7 +726,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
|
||||||
if (dcol != 0) {
|
if (dcol != 0) {
|
||||||
pBlockCol = &(pBlockData->cols[ccol]);
|
pBlockCol = &(pBlockData->cols[ccol]);
|
||||||
tcolId = pBlockCol->colId;
|
tcolId = pBlockCol->colId;
|
||||||
toffset = tsdbGetBlockColOffset(pBlockCol);
|
toffset = pBlockCol->offset;
|
||||||
tlen = pBlockCol->len;
|
tlen = pBlockCol->len;
|
||||||
pDataCol->bitmap = pBlockCol->blen > 0 ? 1 : 0;
|
pDataCol->bitmap = pBlockCol->blen > 0 ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -942,8 +942,8 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
|
||||||
if (tsdbMakeRoom((void **)(&TSDB_READ_BUF(pReadh)), pBlockCol->len) < 0) return -1;
|
if (tsdbMakeRoom((void **)(&TSDB_READ_BUF(pReadh)), pBlockCol->len) < 0) return -1;
|
||||||
if (tsdbMakeRoom((void **)(&TSDB_READ_COMP_BUF(pReadh)), tsize) < 0) return -1;
|
if (tsdbMakeRoom((void **)(&TSDB_READ_COMP_BUF(pReadh)), tsize) < 0) return -1;
|
||||||
|
|
||||||
int64_t offset = pBlock->offset + tsdbBlockStatisSize(pBlock->numOfCols, (uint32_t)pBlock->blkVer) +
|
int64_t offset =
|
||||||
tsdbGetBlockColOffset(pBlockCol);
|
pBlock->offset + tsdbBlockStatisSize(pBlock->numOfCols, (uint32_t)pBlock->blkVer) + pBlockCol->offset;
|
||||||
if (tsdbSeekDFile(pDFile, offset, SEEK_SET) < 0) {
|
if (tsdbSeekDFile(pDFile, offset, SEEK_SET) < 0) {
|
||||||
tsdbError("vgId:%d, failed to load block column data while seek file %s to offset %" PRId64 " since %s",
|
tsdbError("vgId:%d, failed to load block column data while seek file %s to offset %" PRId64 " since %s",
|
||||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), offset, tstrerror(terrno));
|
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), offset, tstrerror(terrno));
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,15 @@
|
||||||
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessAlterStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessAlterStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
static int vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
|
static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp);
|
||||||
|
|
||||||
int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
@ -99,11 +100,11 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp) {
|
int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg *pRsp) {
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
void *pReq;
|
void *pReq;
|
||||||
int len;
|
int32_t len;
|
||||||
int ret;
|
int32_t ret;
|
||||||
|
|
||||||
vTrace("vgId:%d, start to process write request %s, version %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
vTrace("vgId:%d, start to process write request %s, version %" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType),
|
||||||
version);
|
version);
|
||||||
|
|
@ -158,6 +159,9 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRpcMsg
|
||||||
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
pMsg->contLen - sizeof(SMsgHead)) < 0) {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case TDMT_VND_ALTER_CONFIRM:
|
||||||
|
vnodeProcessAlterConfirmReq(pVnode, version, pReq, len, pRsp);
|
||||||
|
break;
|
||||||
case TDMT_VND_ALTER_CONFIG:
|
case TDMT_VND_ALTER_CONFIG:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -212,7 +216,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
vTrace("message in fetch queue is processing");
|
vTrace("message in fetch queue is processing");
|
||||||
char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
char *msgstr = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead));
|
||||||
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
int32_t msgLen = pMsg->contLen - sizeof(SMsgHead);
|
||||||
|
|
@ -267,7 +271,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
|
||||||
pMetaRsp->precision = pVnode->config.tsdbCfg.precision;
|
pMetaRsp->precision = pVnode->config.tsdbCfg.precision;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
int32_t ret = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
int32_t ret = TAOS_SYNC_PROPOSE_OTHER_ERROR;
|
||||||
|
|
||||||
if (syncEnvIsStart()) {
|
if (syncEnvIsStart()) {
|
||||||
|
|
@ -357,7 +361,7 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
SDecoder coder;
|
SDecoder coder;
|
||||||
|
|
||||||
|
|
@ -389,9 +393,9 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
int rcode = 0;
|
int32_t rcode = 0;
|
||||||
SVCreateTbBatchReq req = {0};
|
SVCreateTbBatchReq req = {0};
|
||||||
SVCreateTbReq *pCreateReq;
|
SVCreateTbReq *pCreateReq;
|
||||||
SVCreateTbBatchRsp rsp = {0};
|
SVCreateTbBatchRsp rsp = {0};
|
||||||
|
|
@ -422,7 +426,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop to create table
|
// loop to create table
|
||||||
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pCreateReq = req.pReqs + iReq;
|
pCreateReq = req.pReqs + iReq;
|
||||||
|
|
||||||
// validate hash
|
// validate hash
|
||||||
|
|
@ -477,7 +481,7 @@ _exit:
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessAlterStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessAlterStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVCreateStbReq req = {0};
|
SVCreateStbReq req = {0};
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
|
||||||
|
|
@ -506,9 +510,9 @@ static int vnodeProcessAlterStbReq(SVnode *pVnode, int64_t version, void *pReq,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessDropStbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVDropStbReq req = {0};
|
SVDropStbReq req = {0};
|
||||||
int rcode = TSDB_CODE_SUCCESS;
|
int32_t rcode = TSDB_CODE_SUCCESS;
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
pRsp->msgType = TDMT_VND_CREATE_STB_RSP;
|
||||||
|
|
@ -535,12 +539,12 @@ _exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVAlterTbReq vAlterTbReq = {0};
|
SVAlterTbReq vAlterTbReq = {0};
|
||||||
SVAlterTbRsp vAlterTbRsp = {0};
|
SVAlterTbRsp vAlterTbRsp = {0};
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
int rcode = 0;
|
int32_t rcode = 0;
|
||||||
int ret;
|
int32_t ret;
|
||||||
SEncoder ec = {0};
|
SEncoder ec = {0};
|
||||||
STableMetaRsp vMetaRsp = {0};
|
STableMetaRsp vMetaRsp = {0};
|
||||||
|
|
||||||
|
|
@ -582,12 +586,12 @@ _exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVDropTbBatchReq req = {0};
|
SVDropTbBatchReq req = {0};
|
||||||
SVDropTbBatchRsp rsp = {0};
|
SVDropTbBatchRsp rsp = {0};
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
int ret;
|
int32_t ret;
|
||||||
SArray *tbUids = NULL;
|
SArray *tbUids = NULL;
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
|
||||||
|
|
@ -609,7 +613,7 @@ static int vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq, in
|
||||||
rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp));
|
rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp));
|
||||||
if (tbUids == NULL || rsp.pArray == NULL) goto _exit;
|
if (tbUids == NULL || rsp.pArray == NULL) goto _exit;
|
||||||
|
|
||||||
for (int iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
|
||||||
SVDropTbRsp dropTbRsp = {0};
|
SVDropTbRsp dropTbRsp = {0};
|
||||||
|
|
||||||
|
|
@ -641,7 +645,8 @@ _exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock, SSubmitMsgIter *msgIter, const char *tags) {
|
static int32_t vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock, SSubmitMsgIter *msgIter,
|
||||||
|
const char *tags) {
|
||||||
SSubmitBlkIter blkIter = {0};
|
SSubmitBlkIter blkIter = {0};
|
||||||
STSchema *pSchema = NULL;
|
STSchema *pSchema = NULL;
|
||||||
tb_uid_t suid = 0;
|
tb_uid_t suid = 0;
|
||||||
|
|
@ -675,7 +680,7 @@ static int vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock, SSub
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const char *tags) {
|
static int32_t vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const char *tags) {
|
||||||
ASSERT(pMsg != NULL);
|
ASSERT(pMsg != NULL);
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
SMeta *pMeta = pVnode->pMeta;
|
SMeta *pMeta = pVnode->pMeta;
|
||||||
|
|
@ -692,7 +697,7 @@ static int vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const char
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SSubmitReq *pSubmitReq = (SSubmitReq *)pReq;
|
SSubmitReq *pSubmitReq = (SSubmitReq *)pReq;
|
||||||
SSubmitRsp submitRsp = {0};
|
SSubmitRsp submitRsp = {0};
|
||||||
SSubmitMsgIter msgIter = {0};
|
SSubmitMsgIter msgIter = {0};
|
||||||
|
|
@ -808,7 +813,7 @@ _exit:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVCreateTSmaReq req = {0};
|
SVCreateTSmaReq req = {0};
|
||||||
SDecoder coder;
|
SDecoder coder;
|
||||||
|
|
||||||
|
|
@ -859,3 +864,13 @@ _err:
|
||||||
int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen) {
|
int32_t vnodeProcessCreateTSma(SVnode *pVnode, void *pCont, uint32_t contLen) {
|
||||||
return vnodeProcessCreateTSmaReq(pVnode, 1, pCont, contLen, NULL);
|
return vnodeProcessCreateTSmaReq(pVnode, 1, pCont, contLen, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
|
vInfo("vgId:%d, alter replica confim msg is processed", TD_VID(pVnode));
|
||||||
|
pRsp->msgType = TDMT_VND_ALTER_CONFIRM_RSP;
|
||||||
|
pRsp->code = TSDB_CODE_SUCCESS;
|
||||||
|
pRsp->pCont = NULL;
|
||||||
|
pRsp->contLen = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ int32_t vnodeSyncAlter(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
int32_t code = syncReconfig(pVnode->sync, &cfg);
|
int32_t code = syncReconfig(pVnode->sync, &cfg);
|
||||||
if (code == TAOS_SYNC_PROPOSE_SUCCESS) {
|
if (code == TAOS_SYNC_PROPOSE_SUCCESS) {
|
||||||
// todo refactor
|
// todo refactor
|
||||||
SRpcMsg rsp = {.info = pMsg->info, .code = terrno};
|
SRpcMsg rsp = {.info = pMsg->info, .code = 0};
|
||||||
tmsgSendRsp(&rsp);
|
tmsgSendRsp(&rsp);
|
||||||
return TSDB_CODE_ACTION_IN_PROGRESS;
|
return TSDB_CODE_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ enum {
|
||||||
CTG_OP_UPDATE_VGROUP = 0,
|
CTG_OP_UPDATE_VGROUP = 0,
|
||||||
CTG_OP_UPDATE_TB_META,
|
CTG_OP_UPDATE_TB_META,
|
||||||
CTG_OP_DROP_DB_CACHE,
|
CTG_OP_DROP_DB_CACHE,
|
||||||
|
CTG_OP_DROP_DB_VGROUP,
|
||||||
CTG_OP_DROP_STB_META,
|
CTG_OP_DROP_STB_META,
|
||||||
CTG_OP_DROP_TB_META,
|
CTG_OP_DROP_TB_META,
|
||||||
CTG_OP_UPDATE_USER,
|
CTG_OP_UPDATE_USER,
|
||||||
|
|
@ -266,26 +267,32 @@ typedef struct SCtgUpdateTblMsg {
|
||||||
STableMetaOutput* output;
|
STableMetaOutput* output;
|
||||||
} SCtgUpdateTblMsg;
|
} SCtgUpdateTblMsg;
|
||||||
|
|
||||||
typedef struct SCtgRemoveDBMsg {
|
typedef struct SCtgDropDBMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
} SCtgRemoveDBMsg;
|
} SCtgDropDBMsg;
|
||||||
|
|
||||||
typedef struct SCtgRemoveStbMsg {
|
typedef struct SCtgDropDbVgroupMsg {
|
||||||
|
SCatalog* pCtg;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
} SCtgDropDbVgroupMsg;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct SCtgDropStbMetaMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
char stbName[TSDB_TABLE_NAME_LEN];
|
char stbName[TSDB_TABLE_NAME_LEN];
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
uint64_t suid;
|
uint64_t suid;
|
||||||
} SCtgRemoveStbMsg;
|
} SCtgDropStbMetaMsg;
|
||||||
|
|
||||||
typedef struct SCtgRemoveTblMsg {
|
typedef struct SCtgDropTblMetaMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
uint64_t dbId;
|
uint64_t dbId;
|
||||||
} SCtgRemoveTblMsg;
|
} SCtgDropTblMetaMsg;
|
||||||
|
|
||||||
typedef struct SCtgUpdateUserMsg {
|
typedef struct SCtgUpdateUserMsg {
|
||||||
SCatalog* pCtg;
|
SCatalog* pCtg;
|
||||||
|
|
@ -451,6 +458,7 @@ int32_t ctgGetTbMetaFromCache(CTG_PARAMS, SCtgTbMetaCtx* ctx, STableMeta** pTabl
|
||||||
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *action);
|
int32_t ctgOpUpdateVgroup(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *action);
|
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpDropDbCache(SCtgCacheOperation *action);
|
int32_t ctgOpDropDbCache(SCtgCacheOperation *action);
|
||||||
|
int32_t ctgOpDropDbVgroup(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpDropStbMeta(SCtgCacheOperation *action);
|
int32_t ctgOpDropStbMeta(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpDropTbMeta(SCtgCacheOperation *action);
|
int32_t ctgOpDropTbMeta(SCtgCacheOperation *action);
|
||||||
int32_t ctgOpUpdateUser(SCtgCacheOperation *action);
|
int32_t ctgOpUpdateUser(SCtgCacheOperation *action);
|
||||||
|
|
@ -464,6 +472,7 @@ int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta**
|
||||||
int32_t ctgReadTbVerFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *sver, int32_t *tver, int32_t *tbType, uint64_t *suid, char *stbName);
|
int32_t ctgReadTbVerFromCache(SCatalog *pCtg, const SName *pTableName, int32_t *sver, int32_t *tver, int32_t *tbType, uint64_t *suid, char *stbName);
|
||||||
int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass);
|
int32_t ctgChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass);
|
||||||
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId);
|
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId);
|
||||||
|
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char *dbFName, bool syncReq);
|
||||||
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq);
|
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq);
|
||||||
int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq);
|
int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq);
|
||||||
int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq);
|
int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname);
|
qDebug("QID:0x%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
|
||||||
|
|
||||||
taosArrayPush(pJob->pTasks, &task);
|
taosArrayPush(pJob->pTasks, &task);
|
||||||
|
|
||||||
qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname);
|
qDebug("QID:0x%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +247,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
|
||||||
|
|
||||||
*taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum;
|
*taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum;
|
||||||
if (*taskNum <= 0) {
|
if (*taskNum <= 0) {
|
||||||
ctgError("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, reqId);
|
ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, reqId);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,6 +286,9 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
|
||||||
int32_t taskIdx = 0;
|
int32_t taskIdx = 0;
|
||||||
for (int32_t i = 0; i < dbVgNum; ++i) {
|
for (int32_t i = 0; i < dbVgNum; ++i) {
|
||||||
char* dbFName = taosArrayGet(pReq->pDbVgroup, i);
|
char* dbFName = taosArrayGet(pReq->pDbVgroup, i);
|
||||||
|
if (pReq->forceUpdate) {
|
||||||
|
ctgDropDbVgroupEnqueue(pCtg, dbFName, true);
|
||||||
|
}
|
||||||
CTG_ERR_JRET(ctgInitGetDbVgTask(pJob, taskIdx++, dbFName));
|
CTG_ERR_JRET(ctgInitGetDbVgTask(pJob, taskIdx++, dbFName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -301,6 +304,9 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
|
||||||
|
|
||||||
for (int32_t i = 0; i < tbMetaNum; ++i) {
|
for (int32_t i = 0; i < tbMetaNum; ++i) {
|
||||||
SName* name = taosArrayGet(pReq->pTableMeta, i);
|
SName* name = taosArrayGet(pReq->pTableMeta, i);
|
||||||
|
if (pReq->forceUpdate) {
|
||||||
|
catalogRemoveTableMeta(pCtg, name);
|
||||||
|
}
|
||||||
CTG_ERR_JRET(ctgInitGetTbMetaTask(pJob, taskIdx++, name));
|
CTG_ERR_JRET(ctgInitGetTbMetaTask(pJob, taskIdx++, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {
|
||||||
"drop DB",
|
"drop DB",
|
||||||
ctgOpDropDbCache
|
ctgOpDropDbCache
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
CTG_OP_DROP_DB_VGROUP,
|
||||||
|
"drop DBVgroup",
|
||||||
|
ctgOpDropDbVgroup
|
||||||
|
},
|
||||||
{
|
{
|
||||||
CTG_OP_DROP_STB_META,
|
CTG_OP_DROP_STB_META,
|
||||||
"drop stbMeta",
|
"drop stbMeta",
|
||||||
|
|
@ -563,9 +568,9 @@ int32_t ctgEnqueue(SCatalog* pCtg, SCtgCacheOperation *operation) {
|
||||||
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) {
|
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgCacheOperation action= {.opId = CTG_OP_DROP_DB_CACHE};
|
SCtgCacheOperation action= {.opId = CTG_OP_DROP_DB_CACHE};
|
||||||
SCtgRemoveDBMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveDBMsg));
|
SCtgDropDBMsg *msg = taosMemoryMalloc(sizeof(SCtgDropDBMsg));
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveDBMsg));
|
ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropDBMsg));
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -590,13 +595,43 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char *dbFName, bool syncOp) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SCtgCacheOperation action= {.opId = CTG_OP_DROP_DB_VGROUP, .syncOp = syncOp};
|
||||||
|
SCtgDropDbVgroupMsg *msg = taosMemoryMalloc(sizeof(SCtgDropDbVgroupMsg));
|
||||||
|
if (NULL == msg) {
|
||||||
|
ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropDbVgroupMsg));
|
||||||
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *p = strchr(dbFName, '.');
|
||||||
|
if (p && CTG_IS_SYS_DBNAME(p + 1)) {
|
||||||
|
dbFName = p + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg->pCtg = pCtg;
|
||||||
|
strncpy(msg->dbFName, dbFName, sizeof(msg->dbFName));
|
||||||
|
|
||||||
|
action.data = msg;
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgEnqueue(pCtg, &action));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
taosMemoryFreeClear(action.data);
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncOp) {
|
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncOp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgCacheOperation action= {.opId = CTG_OP_DROP_STB_META, .syncOp = syncOp};
|
SCtgCacheOperation action= {.opId = CTG_OP_DROP_STB_META, .syncOp = syncOp};
|
||||||
SCtgRemoveStbMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveStbMsg));
|
SCtgDropStbMetaMsg *msg = taosMemoryMalloc(sizeof(SCtgDropStbMetaMsg));
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveStbMsg));
|
ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropStbMetaMsg));
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -623,9 +658,9 @@ _return:
|
||||||
int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncOp) {
|
int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncOp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgCacheOperation action= {.opId = CTG_OP_DROP_TB_META, .syncOp = syncOp};
|
SCtgCacheOperation action= {.opId = CTG_OP_DROP_TB_META, .syncOp = syncOp};
|
||||||
SCtgRemoveTblMsg *msg = taosMemoryMalloc(sizeof(SCtgRemoveTblMsg));
|
SCtgDropTblMetaMsg *msg = taosMemoryMalloc(sizeof(SCtgDropTblMetaMsg));
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
ctgError("malloc %d failed", (int32_t)sizeof(SCtgRemoveTblMsg));
|
ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropTblMetaMsg));
|
||||||
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1281,7 +1316,7 @@ _return:
|
||||||
|
|
||||||
int32_t ctgOpDropDbCache(SCtgCacheOperation *operation) {
|
int32_t ctgOpDropDbCache(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgRemoveDBMsg *msg = operation->data;
|
SCtgDropDBMsg *msg = operation->data;
|
||||||
SCatalog* pCtg = msg->pCtg;
|
SCatalog* pCtg = msg->pCtg;
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
@ -1304,6 +1339,33 @@ _return:
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SCtgDropDbVgroupMsg *msg = operation->data;
|
||||||
|
SCatalog* pCtg = msg->pCtg;
|
||||||
|
|
||||||
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
ctgGetDBCache(msg->pCtg, msg->dbFName, &dbCache);
|
||||||
|
if (NULL == dbCache) {
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_ERR_RET(ctgWAcquireVgInfo(pCtg, dbCache));
|
||||||
|
|
||||||
|
ctgFreeVgInfo(dbCache->vgInfo);
|
||||||
|
dbCache->vgInfo = NULL;
|
||||||
|
|
||||||
|
ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName);
|
||||||
|
|
||||||
|
ctgWReleaseVgInfo(dbCache);
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
taosMemoryFreeClear(msg);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
@ -1353,7 +1415,7 @@ _return:
|
||||||
|
|
||||||
int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
|
int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgRemoveStbMsg *msg = operation->data;
|
SCtgDropStbMetaMsg *msg = operation->data;
|
||||||
SCatalog* pCtg = msg->pCtg;
|
SCatalog* pCtg = msg->pCtg;
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
@ -1399,7 +1461,7 @@ _return:
|
||||||
|
|
||||||
int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
|
int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCtgRemoveTblMsg *msg = operation->data;
|
SCtgDropTblMetaMsg *msg = operation->data;
|
||||||
SCatalog* pCtg = msg->pCtg;
|
SCatalog* pCtg = msg->pCtg;
|
||||||
|
|
||||||
SCtgDBCache *dbCache = NULL;
|
SCtgDBCache *dbCache = NULL;
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,22 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId) {
|
|
||||||
|
/*
|
||||||
|
prepare SQL:
|
||||||
|
create database db1;
|
||||||
|
use db1;
|
||||||
|
create stable st1 (ts timestamp, f1 int) tags(t1 int);
|
||||||
|
create table tb1 using st1 tags(1);
|
||||||
|
insert into tb1 values (now, 1);
|
||||||
|
create qnode on dnode 1;
|
||||||
|
create user user1 pass "abc";
|
||||||
|
create database db2;
|
||||||
|
grant write on db2.* to user1;
|
||||||
|
create function udf1 as '/tmp/libudf1.so' outputtype int;
|
||||||
|
create aggregate function udf2 as '/tmp/libudf2.so' outputtype int;
|
||||||
|
*/
|
||||||
|
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId, bool forceUpdate) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCatalogReq req = {0};
|
SCatalogReq req = {0};
|
||||||
req.pTableMeta = taosArrayInit(2, sizeof(SName));
|
req.pTableMeta = taosArrayInit(2, sizeof(SName));
|
||||||
|
|
@ -144,6 +159,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps
|
||||||
req.pIndex = NULL;//taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
|
req.pIndex = NULL;//taosArrayInit(2, TSDB_INDEX_FNAME_LEN);
|
||||||
req.pUser = taosArrayInit(2, sizeof(SUserAuthInfo));
|
req.pUser = taosArrayInit(2, sizeof(SUserAuthInfo));
|
||||||
req.qNodeRequired = true;
|
req.qNodeRequired = true;
|
||||||
|
req.forceUpdate = forceUpdate;
|
||||||
|
|
||||||
SName name = {0};
|
SName name = {0};
|
||||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
||||||
pPhysiChildren = pSortNode->node.pChildren;
|
pPhysiChildren = pSortNode->node.pChildren;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: {
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: {
|
||||||
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
||||||
pPhysiChildren = pIntNode->window.node.pChildren;
|
pPhysiChildren = pIntNode->window.node.pChildren;
|
||||||
break;
|
break;
|
||||||
|
|
@ -429,7 +429,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey, pTblScanNode->scanRange.ekey);
|
EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey,
|
||||||
|
pTblScanNode->scanRange.ekey);
|
||||||
EXPLAIN_ROW_END();
|
EXPLAIN_ROW_END();
|
||||||
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1));
|
||||||
|
|
||||||
|
|
@ -701,7 +702,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: {
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: {
|
||||||
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk));
|
EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
|
|
@ -784,7 +785,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW: {
|
case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW: {
|
||||||
SStateWinodwPhysiNode *pStateNode = (SStateWinodwPhysiNode *)pNode;
|
SStateWinodwPhysiNode *pStateNode = (SStateWinodwPhysiNode *)pNode;
|
||||||
|
|
||||||
EXPLAIN_ROW_NEW(level, EXPLAIN_STATE_WINDOW_FORMAT, nodesGetNameFromColumnNode(((STargetNode*)pStateNode->pStateKey)->pExpr));
|
EXPLAIN_ROW_NEW(level, EXPLAIN_STATE_WINDOW_FORMAT,
|
||||||
|
nodesGetNameFromColumnNode(((STargetNode *)pStateNode->pStateKey)->pExpr));
|
||||||
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
|
||||||
if (pResNode->pExecInfo) {
|
if (pResNode->pExecInfo) {
|
||||||
QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen));
|
QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen));
|
||||||
|
|
|
||||||
|
|
@ -303,13 +303,17 @@ typedef struct SScanInfo {
|
||||||
int32_t numOfDesc;
|
int32_t numOfDesc;
|
||||||
} SScanInfo;
|
} SScanInfo;
|
||||||
|
|
||||||
|
typedef struct SSampleExecInfo {
|
||||||
|
double sampleRatio; // data block sample ratio, 1 by default
|
||||||
|
uint32_t seed; // random seed value
|
||||||
|
} SSampleExecInfo;
|
||||||
|
|
||||||
typedef struct STableScanInfo {
|
typedef struct STableScanInfo {
|
||||||
void* dataReader;
|
void* dataReader;
|
||||||
SReadHandle readHandle;
|
SReadHandle readHandle;
|
||||||
|
|
||||||
SFileBlockLoadRecorder readRecorder;
|
SFileBlockLoadRecorder readRecorder;
|
||||||
int64_t numOfRows;
|
int64_t numOfRows;
|
||||||
int64_t elapsedTime;
|
|
||||||
// int32_t prevGroupId; // previous table group id
|
// int32_t prevGroupId; // previous table group id
|
||||||
SScanInfo scanInfo;
|
SScanInfo scanInfo;
|
||||||
int32_t scanTimes;
|
int32_t scanTimes;
|
||||||
|
|
@ -330,7 +334,6 @@ typedef struct STableScanInfo {
|
||||||
SQueryTableDataCond cond;
|
SQueryTableDataCond cond;
|
||||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||||
int32_t dataBlockLoadFlag;
|
int32_t dataBlockLoadFlag;
|
||||||
double sampleRatio; // data block sample ratio, 1 by default
|
|
||||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
|
||||||
|
|
||||||
SArray* pGroupCols;
|
SArray* pGroupCols;
|
||||||
|
|
@ -339,6 +342,7 @@ typedef struct STableScanInfo {
|
||||||
int32_t groupKeyLen; // total group by column width
|
int32_t groupKeyLen; // total group by column width
|
||||||
SHashObj* pGroupSet; // quick locate the window object for each result
|
SHashObj* pGroupSet; // quick locate the window object for each result
|
||||||
|
|
||||||
|
SSampleExecInfo sample; // sample execution info
|
||||||
int32_t curTWinIdx;
|
int32_t curTWinIdx;
|
||||||
} STableScanInfo;
|
} STableScanInfo;
|
||||||
|
|
||||||
|
|
@ -733,7 +737,7 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWin
|
||||||
int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type, int16_t bytes,
|
int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t type, int16_t bytes,
|
||||||
int32_t groupId, SDiskbasedBuf* pBuf, SExecTaskInfo* pTaskInfo, SAggSupporter* pAggSup);
|
int32_t groupId, SDiskbasedBuf* pBuf, SExecTaskInfo* pTaskInfo, SAggSupporter* pAggSup);
|
||||||
void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput);
|
void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput);
|
||||||
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
int32_t setDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||||
SArray* pColList);
|
SArray* pColList);
|
||||||
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, STimeWindow* win);
|
void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key, STimeWindow* win);
|
||||||
|
|
@ -768,7 +772,11 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
|
||||||
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
|
||||||
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup);
|
SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup);
|
||||||
|
|
||||||
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, tsdbReaderT pDataReader, SReadHandle* pHandle, SArray* groupKyes, SExecTaskInfo* pTaskInfo);
|
||||||
|
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
|
||||||
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo,
|
||||||
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
@ -780,9 +788,6 @@ SOperatorInfo *createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
|
||||||
|
|
||||||
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pSortInfo, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, SSDataBlock* pResBlock, const SName* pName,
|
|
||||||
SNode* pCondition, SEpSet epset, SArray* colList,
|
|
||||||
SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId);
|
|
||||||
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
|
||||||
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
|
||||||
STimeWindowAggSupp *pTwAggSupp, SExecTaskInfo* pTaskInfo);
|
STimeWindowAggSupp *pTwAggSupp, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
@ -800,9 +805,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
|
||||||
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
SExprInfo* pScalarExprInfo, int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle,
|
SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHandle, SArray* pTableIdList,
|
||||||
SArray* pTableIdList, STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo,
|
STableScanPhysiNode* pTableScanNode, SExecTaskInfo* pTaskInfo, STimeWindowAggSupp* pTwSup);
|
||||||
STimeWindowAggSupp* pTwSup);
|
|
||||||
|
|
||||||
|
|
||||||
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols,
|
||||||
|
|
@ -818,7 +822,6 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
|
||||||
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
|
||||||
|
|
||||||
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo);
|
SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo);
|
||||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pExpr, int32_t numOfOutput, SSDataBlock* pResBlock, SArray* pColMatchInfo, STableListInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo);
|
|
||||||
|
|
||||||
SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
|
||||||
SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap,
|
SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, int64_t gap,
|
||||||
|
|
@ -836,8 +839,6 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
|
|
||||||
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol);
|
void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol);
|
||||||
|
|
||||||
void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
|
||||||
|
|
||||||
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||||
int32_t checkForQueryBuf(size_t numOfTables);
|
int32_t checkForQueryBuf(size_t numOfTables);
|
||||||
|
|
||||||
|
|
@ -872,17 +873,15 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
|
||||||
int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
|
int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
|
||||||
int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length);
|
int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length);
|
||||||
|
|
||||||
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts,
|
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
|
||||||
SInterval* pInterval, int32_t precision, STimeWindow* win);
|
int32_t precision, STimeWindow* win);
|
||||||
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn,
|
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
|
||||||
int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, STableQueryInfo* item,
|
__block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
|
||||||
int32_t order);
|
|
||||||
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
|
||||||
int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
||||||
int32_t initStateAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
int32_t initStateAggSupporter(SStreamAggSupporter* pSup, const char* pKey);
|
||||||
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize);
|
SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize);
|
||||||
SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap,
|
SResultWindowInfo* getSessionTimeWindow(SArray* pWinInfos, TSKEY ts, int64_t gap, int32_t* pIndex);
|
||||||
int32_t* pIndex);
|
|
||||||
int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows,
|
int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t rows,
|
||||||
int32_t start, int64_t gap, SHashObj* pStDeleted);
|
int32_t start, int64_t gap, SHashObj* pStDeleted);
|
||||||
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
bool functionNeedToExecute(SqlFunctionCtx* pCtx);
|
||||||
|
|
@ -890,6 +889,7 @@ int64_t getSmaWaterMark(int64_t interval, double filesFactor);
|
||||||
bool isSmaStream(int8_t triggerType);
|
bool isSmaStream(int8_t triggerType);
|
||||||
|
|
||||||
int32_t compareTimeWindow(const void* p1, const void* p2, const void* param);
|
int32_t compareTimeWindow(const void* p1, const void* p2, const void* param);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,6 @@ typedef struct SCompSupporter {
|
||||||
int32_t order;
|
int32_t order;
|
||||||
} SCompSupporter;
|
} SCompSupporter;
|
||||||
|
|
||||||
int32_t getRowNumForMultioutput(STaskAttr* pQueryAttr, bool topBottomQuery, bool stable) {
|
|
||||||
if (pQueryAttr && (!stable)) {
|
|
||||||
for (int16_t i = 0; i < pQueryAttr->numOfOutput; ++i) {
|
|
||||||
// if (pQueryAttr->pExpr1[i].base. == FUNCTION_TOP || pQueryAttr->pExpr1[i].base.functionId == FUNCTION_BOTTOM) {
|
|
||||||
// return (int32_t)pQueryAttr->pExpr1[i].base.param[0].i;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
|
int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
|
||||||
|
|
@ -113,35 +101,6 @@ void closeResultRow(SResultRow* pResultRow) {
|
||||||
pResultRow->closed = true;
|
pResultRow->closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearResultRow(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow) {
|
|
||||||
if (pResultRow == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// the result does not put into the SDiskbasedBuf, ignore it.
|
|
||||||
if (pResultRow->pageId >= 0) {
|
|
||||||
SFilePage *page = getBufPage(pRuntimeEnv->pResultBuf, pResultRow->pageId);
|
|
||||||
|
|
||||||
int16_t offset = 0;
|
|
||||||
for (int32_t i = 0; i < pRuntimeEnv->pQueryAttr->numOfOutput; ++i) {
|
|
||||||
struct SResultRowEntryInfo *pEntryInfo = NULL;//pResultRow->pEntryInfo[i];
|
|
||||||
|
|
||||||
// int16_t size = pRuntimeEnv->pQueryAttr->pExpr1[i].base.resSchema.bytes;
|
|
||||||
// char * s = getPosInResultPage(pRuntimeEnv->pQueryAttr, page, pResultRow->offset, offset);
|
|
||||||
// memset(s, 0, size);
|
|
||||||
|
|
||||||
// offset += size;
|
|
||||||
cleanupResultRowEntry(pEntryInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pResultRow->numOfRows = 0;
|
|
||||||
pResultRow->pageId = -1;
|
|
||||||
pResultRow->offset = -1;
|
|
||||||
pResultRow->closed = false;
|
|
||||||
pResultRow->win = TSWINDOW_INITIALIZER;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO refactor: use macro
|
// TODO refactor: use macro
|
||||||
SResultRowEntryInfo* getResultCell(const SResultRow* pRow, int32_t index, const int32_t* offset) {
|
SResultRowEntryInfo* getResultCell(const SResultRow* pRow, int32_t index, const int32_t* offset) {
|
||||||
assert(index >= 0 && offset != NULL);
|
assert(index >= 0 && offset != NULL);
|
||||||
|
|
|
||||||
|
|
@ -2413,6 +2413,9 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
|
||||||
pRsp->compLen = htonl(pRsp->compLen);
|
pRsp->compLen = htonl(pRsp->compLen);
|
||||||
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
pRsp->numOfCols = htonl(pRsp->numOfCols);
|
||||||
pRsp->useconds = htobe64(pRsp->useconds);
|
pRsp->useconds = htobe64(pRsp->useconds);
|
||||||
|
|
||||||
|
ASSERT(pSourceDataInfo->pRsp != NULL);
|
||||||
|
qDebug("fetch rsp received, index:%d, rows:%d", pSourceDataInfo->index, pRsp->numOfRows);
|
||||||
} else {
|
} else {
|
||||||
pSourceDataInfo->code = code;
|
pSourceDataInfo->code = code;
|
||||||
}
|
}
|
||||||
|
|
@ -2461,6 +2464,8 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, sourceIndex);
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, sourceIndex);
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, sourceIndex);
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, sourceIndex);
|
||||||
|
|
||||||
|
ASSERT(pDataInfo->status == EX_SOURCE_DATA_NOT_READY);
|
||||||
|
|
||||||
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", %d/%" PRIzu, GET_TASKID(pTaskInfo),
|
qDebug("%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%" PRIx64 ", %d/%" PRIzu, GET_TASKID(pTaskInfo),
|
||||||
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
pSource->addr.nodeId, pSource->addr.epSet.eps[0].fqdn, pSource->taskId, sourceIndex, totalSources);
|
||||||
|
|
||||||
|
|
@ -2514,7 +2519,7 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
int32_t setDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadInfo, int32_t numOfRows, char* pData,
|
||||||
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
int32_t compLen, int32_t numOfOutput, int64_t startTs, uint64_t* total,
|
||||||
SArray* pColList) {
|
SArray* pColList) {
|
||||||
if (pColList == NULL) { // data from other sources
|
if (pColList == NULL) { // data from other sources
|
||||||
|
|
@ -2638,7 +2643,6 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
int32_t completed = 0;
|
int32_t completed = 0;
|
||||||
for (int32_t i = 0; i < totalSources; ++i) {
|
for (int32_t i = 0; i < totalSources; ++i) {
|
||||||
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, i);
|
||||||
|
|
||||||
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
if (pDataInfo->status == EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
completed += 1;
|
completed += 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2648,6 +2652,11 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pDataInfo->code != TSDB_CODE_SUCCESS) {
|
||||||
|
code = pDataInfo->code;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
SRetrieveTableRsp* pRsp = pDataInfo->pRsp;
|
||||||
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, i);
|
SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, i);
|
||||||
|
|
||||||
|
|
@ -2665,7 +2674,7 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
}
|
}
|
||||||
|
|
||||||
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
||||||
code = setSDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
code = setDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
||||||
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
|
@ -2685,6 +2694,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
pLoadInfo->totalSize);
|
pLoadInfo->totalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
taosMemoryFreeClear(pDataInfo->pRsp);
|
||||||
|
|
||||||
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
if (pDataInfo->status != EX_SOURCE_DATA_EXHAUSTED) {
|
||||||
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
pDataInfo->status = EX_SOURCE_DATA_NOT_READY;
|
||||||
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
||||||
|
|
@ -2694,7 +2705,6 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pDataInfo->pRsp);
|
|
||||||
return pExchangeInfo->pResult;
|
return pExchangeInfo->pResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2708,34 +2718,6 @@ _error:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo* pOperator) {
|
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
|
||||||
|
|
||||||
if (pOperator->status == OP_RES_TO_RETURN) {
|
|
||||||
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
|
||||||
int64_t startTs = taosGetTimestampUs();
|
|
||||||
|
|
||||||
// Asynchronously send all fetch requests to all sources.
|
|
||||||
for (int32_t i = 0; i < totalSources; ++i) {
|
|
||||||
int32_t code = doSendFetchDataRequest(pExchangeInfo, pTaskInfo, i);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t endTs = taosGetTimestampUs();
|
|
||||||
qDebug("%s send all fetch request to %" PRIzu " sources completed, elapsed:%" PRId64, GET_TASKID(pTaskInfo),
|
|
||||||
totalSources, endTs - startTs);
|
|
||||||
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
|
||||||
pOperator->status = OP_RES_TO_RETURN;
|
|
||||||
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
||||||
SExchangeInfo* pExchangeInfo = pOperator->info;
|
SExchangeInfo* pExchangeInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
@ -2753,10 +2735,11 @@ static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t endTs = taosGetTimestampUs();
|
int64_t endTs = taosGetTimestampUs();
|
||||||
qDebug("%s send all fetch request to %" PRIzu " sources completed, elapsed:%" PRId64, GET_TASKID(pTaskInfo),
|
qDebug("%s send all fetch requests to %" PRIzu " sources completed, elapsed:%" PRId64, GET_TASKID(pTaskInfo),
|
||||||
totalSources, endTs - startTs);
|
totalSources, endTs - startTs);
|
||||||
|
|
||||||
tsem_wait(&pExchangeInfo->ready);
|
tsem_wait(&pExchangeInfo->ready);
|
||||||
|
pOperator->status = OP_RES_TO_RETURN;
|
||||||
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
pOperator->cost.openCost = taosGetTimestampUs() - startTs;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
@ -2804,7 +2787,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
SSDataBlock* pRes = pExchangeInfo->pResult;
|
SSDataBlock* pRes = pExchangeInfo->pResult;
|
||||||
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
SRetrieveTableRsp* pTableRsp = pDataInfo->pRsp;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
setSDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
setDataBlockFromFetchRsp(pExchangeInfo->pResult, pLoadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
||||||
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
pTableRsp->compLen, pTableRsp->numOfCols, startTs, &pDataInfo->totalRows, NULL);
|
||||||
|
|
||||||
if (pRsp->completed == 1) {
|
if (pRsp->completed == 1) {
|
||||||
|
|
@ -2870,7 +2853,8 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
|
||||||
if (pExchangeInfo->seqLoadData) {
|
if (pExchangeInfo->seqLoadData) {
|
||||||
return seqLoadRemoteData(pOperator);
|
return seqLoadRemoteData(pOperator);
|
||||||
} else {
|
} else {
|
||||||
return concurrentlyLoadRemoteData(pOperator);
|
return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo);
|
||||||
|
// return concurrentlyLoadRemoteData(pOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2896,34 +2880,38 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, const SNodeList* pSources, SSDataBlock* pBlock,
|
static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo* pInfo) {
|
||||||
SExecTaskInfo* pTaskInfo) {
|
size_t numOfSources = LIST_LENGTH(pExNode->pSrcEndPoints);
|
||||||
|
|
||||||
|
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
|
||||||
|
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
||||||
|
if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfSources; ++i) {
|
||||||
|
SNodeListNode* pNode = nodesListGetNode((SNodeList*)pExNode->pSrcEndPoints, i);
|
||||||
|
taosArrayPush(pInfo->pSources, pNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return initDataSource(numOfSources, pInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo) {
|
||||||
SExchangeInfo* pInfo = taosMemoryCalloc(1, sizeof(SExchangeInfo));
|
SExchangeInfo* pInfo = taosMemoryCalloc(1, sizeof(SExchangeInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numOfSources = LIST_LENGTH(pSources);
|
int32_t code = initExchangeOperator(pExNode, pInfo);
|
||||||
pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode));
|
|
||||||
pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo));
|
|
||||||
if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) {
|
|
||||||
goto _error;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfSources; ++i) {
|
|
||||||
SNodeListNode* pNode = nodesListGetNode((SNodeList*)pSources, i);
|
|
||||||
taosArrayPush(pInfo->pSources, pNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = initDataSource(numOfSources, pInfo);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pResult = pBlock;
|
pInfo->seqLoadData = false;
|
||||||
pInfo->seqLoadData = true;
|
pInfo->pTransporter = pTransporter;
|
||||||
|
pInfo->pResult = createResDataBlock(pExNode->node.pOutputDataBlockDesc);
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
|
|
||||||
pOperator->name = "ExchangeOperator";
|
pOperator->name = "ExchangeOperator";
|
||||||
|
|
@ -2931,17 +2919,16 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, const SNodeList* p
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfExprs = pBlock->info.numOfCols;
|
pOperator->numOfExprs = pInfo->pResult->info.numOfCols;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL,
|
||||||
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
destroyExchangeOperatorInfo, NULL, NULL, NULL);
|
||||||
pInfo->pTransporter = pTransporter;
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
destroyExchangeOperatorInfo(pInfo, numOfSources);
|
destroyExchangeOperatorInfo(pInfo, LIST_LENGTH(pExNode->pSrcEndPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
|
|
@ -4530,9 +4517,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) {
|
||||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode;
|
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, (SExchangePhysiNode*)pPhyNode, pTaskInfo);
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc);
|
|
||||||
return createExchangeOperatorInfo(pHandle->pMsgCb->clientRpc, pExchange->pSrcEndPoints, pResBlock, pTaskInfo);
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) {
|
||||||
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
|
SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table.
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
|
|
@ -4560,41 +4545,16 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return pOperator;
|
return pOperator;
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) {
|
||||||
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode;
|
||||||
SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan;
|
return createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pTaskInfo);
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
|
||||||
SArray* colList =
|
|
||||||
extractColMatchInfo(pScanNode->pScanCols, pDescNode, &numOfOutputCols, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
|
||||||
SOperatorInfo* pOperator = createSysTableScanOperatorInfo(
|
|
||||||
pHandle, pResBlock, &pScanNode->tableName, pScanNode->node.pConditions, pSysScanPhyNode->mgmtEpSet, colList,
|
|
||||||
pTaskInfo, pSysScanPhyNode->showRewrite, pSysScanPhyNode->accountId);
|
|
||||||
return pOperator;
|
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) {
|
||||||
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode;
|
STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pScanPhyNode->node.pOutputDataBlockDesc;
|
|
||||||
|
|
||||||
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
|
||||||
|
|
||||||
int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo, pTagCond);
|
int32_t code = getTableList(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableListInfo, pTagCond);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t num = 0;
|
return createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo);
|
||||||
SExprInfo* pExprInfo = createExprInfo(pScanPhyNode->pScanPseudoCols, NULL, &num);
|
|
||||||
|
|
||||||
int32_t numOfOutputCols = 0;
|
|
||||||
SArray* colList = extractColMatchInfo(pScanPhyNode->pScanPseudoCols, pDescNode, &numOfOutputCols, pTaskInfo,
|
|
||||||
COL_MATCH_FROM_COL_ID);
|
|
||||||
|
|
||||||
SOperatorInfo* pOperator =
|
|
||||||
createTagScanOperatorInfo(pHandle, pExprInfo, num, pResBlock, colList, pTableListInfo, pTaskInfo);
|
|
||||||
return pOperator;
|
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
@ -4641,7 +4601,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
pOptr =
|
pOptr =
|
||||||
createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo);
|
createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo);
|
||||||
}
|
}
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
|
||||||
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
|
||||||
|
|
@ -4972,7 +4932,8 @@ int32_t getTableList(void* metaHandle, int32_t tableType, uint64_t tableUid, STa
|
||||||
|
|
||||||
if (tableType == TSDB_SUPER_TABLE) {
|
if (tableType == TSDB_SUPER_TABLE) {
|
||||||
if (pTagCond) {
|
if (pTagCond) {
|
||||||
SIndexMetaArg metaArg = {.metaEx = metaHandle, .metaHandle = tsdbGetIdx(metaHandle), .suid = tableUid};
|
SIndexMetaArg metaArg = {
|
||||||
|
.metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = tsdbGetIvtIdx(metaHandle), .suid = tableUid};
|
||||||
|
|
||||||
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
SArray* res = taosArrayInit(8, sizeof(uint64_t));
|
||||||
code = doFilterTag(pTagCond, &metaArg, res);
|
code = doFilterTag(pTagCond, &metaArg, res);
|
||||||
|
|
@ -5158,45 +5119,6 @@ _complete:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo) {
|
|
||||||
const int32_t DEFAULT_RESULT_MSG_SIZE = 1024 * (1024 + 512);
|
|
||||||
|
|
||||||
// the minimum number of rows for projection query
|
|
||||||
const int32_t MIN_ROWS_FOR_PRJ_QUERY = 8192;
|
|
||||||
const int32_t DEFAULT_MIN_ROWS = 4096;
|
|
||||||
|
|
||||||
const float THRESHOLD_RATIO = 0.85f;
|
|
||||||
|
|
||||||
// if (isProjQuery(pQueryAttr)) {
|
|
||||||
// int32_t numOfRes = DEFAULT_RESULT_MSG_SIZE / pQueryAttr->resultRowSize;
|
|
||||||
// if (numOfRes < MIN_ROWS_FOR_PRJ_QUERY) {
|
|
||||||
// numOfRes = MIN_ROWS_FOR_PRJ_QUERY;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pResultInfo->capacity = numOfRes;
|
|
||||||
// } else { // in case of non-prj query, a smaller output buffer will be used.
|
|
||||||
// pResultInfo->capacity = DEFAULT_MIN_ROWS;
|
|
||||||
// }
|
|
||||||
|
|
||||||
pResultInfo->threshold = (int32_t)(pResultInfo->capacity * THRESHOLD_RATIO);
|
|
||||||
pResultInfo->totalRows = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO refactor
|
|
||||||
void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) {
|
|
||||||
if (pFilter == NULL || numOfFilters == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfFilters; i++) {
|
|
||||||
if (pFilter[i].filterstr && pFilter[i].pz) {
|
|
||||||
taosMemoryFree((void*)(pFilter[i].pz));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosMemoryFree(pFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
static void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
||||||
taosArrayDestroy(pTableqinfoList->pTableList);
|
taosArrayDestroy(pTableqinfoList->pTableList);
|
||||||
taosHashCleanup(pTableqinfoList->map);
|
taosHashCleanup(pTableqinfoList->map);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,15 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
|
||||||
|
|
||||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
int32_t dataLen = getJsonValueLen(val);
|
||||||
|
|
||||||
|
if (memcmp(pkey->pData, val, dataLen) == 0){
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||||
int32_t len = varDataLen(val);
|
int32_t len = varDataLen(val);
|
||||||
if (len == varDataLen(pkey->pData) && memcmp(varDataVal(pkey->pData), varDataVal(val), len) == 0) {
|
if (len == varDataLen(pkey->pData) && memcmp(varDataVal(pkey->pData), varDataVal(val), len) == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -129,7 +137,10 @@ void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock*
|
||||||
} else {
|
} else {
|
||||||
pkey->isNull = false;
|
pkey->isNull = false;
|
||||||
char* val = colDataGetData(pColInfoData, rowIndex);
|
char* val = colDataGetData(pColInfoData, rowIndex);
|
||||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
int32_t dataLen = getJsonValueLen(val);
|
||||||
|
memcpy(pkey->pData, val, dataLen);
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||||
memcpy(pkey->pData, val, varDataTLen(val));
|
memcpy(pkey->pData, val, varDataTLen(val));
|
||||||
ASSERT(varDataTLen(val) <= pkey->bytes);
|
ASSERT(varDataTLen(val) <= pkey->bytes);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -153,7 +164,11 @@ int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
|
||||||
}
|
}
|
||||||
|
|
||||||
isNull[i] = 0;
|
isNull[i] = 0;
|
||||||
if (IS_VAR_DATA_TYPE(pkey->type)) {
|
if (pkey->type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
int32_t dataLen = getJsonValueLen(pkey->pData);
|
||||||
|
memcpy(pStart, (pkey->pData), dataLen);
|
||||||
|
pStart += dataLen;
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pkey->type)) {
|
||||||
varDataCopy(pStart, pkey->pData);
|
varDataCopy(pStart, pkey->pData);
|
||||||
pStart += varDataTLen(pkey->pData);
|
pStart += varDataTLen(pkey->pData);
|
||||||
ASSERT(varDataTLen(pkey->pData) <= pkey->bytes);
|
ASSERT(varDataTLen(pkey->pData) <= pkey->bytes);
|
||||||
|
|
@ -178,7 +193,10 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
|
||||||
char* dest = GET_ROWCELL_INTERBUF(pEntryInfo);
|
char* dest = GET_ROWCELL_INTERBUF(pEntryInfo);
|
||||||
char* data = colDataGetData(pColInfoData, rowIndex);
|
char* data = colDataGetData(pColInfoData, rowIndex);
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
int32_t dataLen = getJsonValueLen(data);
|
||||||
|
memcpy(dest, data, dataLen);
|
||||||
|
} else if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
|
||||||
varDataCopy(dest, data);
|
varDataCopy(dest, data);
|
||||||
} else {
|
} else {
|
||||||
memcpy(dest, data, pColInfoData->info.bytes);
|
memcpy(dest, data, pColInfoData->info.bytes);
|
||||||
|
|
@ -447,6 +465,16 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
||||||
if (colDataIsNull_s(pColInfoData, j)) {
|
if (colDataIsNull_s(pColInfoData, j)) {
|
||||||
offset[(*rows)] = -1;
|
offset[(*rows)] = -1;
|
||||||
contentLen = 0;
|
contentLen = 0;
|
||||||
|
} else if(pColInfoData->info.type == TSDB_DATA_TYPE_JSON){
|
||||||
|
offset[*rows] = (*columnLen);
|
||||||
|
char* src = colDataGetData(pColInfoData, j);
|
||||||
|
int32_t dataLen = getJsonValueLen(src);
|
||||||
|
|
||||||
|
memcpy(data + (*columnLen), src, dataLen);
|
||||||
|
int32_t v = (data + (*columnLen) + dataLen - (char*)pPage);
|
||||||
|
ASSERT(v > 0);
|
||||||
|
|
||||||
|
contentLen = dataLen;
|
||||||
} else {
|
} else {
|
||||||
offset[*rows] = (*columnLen);
|
offset[*rows] = (*columnLen);
|
||||||
char* src = colDataGetData(pColInfoData, j);
|
char* src = colDataGetData(pColInfoData, j);
|
||||||
|
|
|
||||||
|
|
@ -38,15 +38,26 @@
|
||||||
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
|
||||||
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
#define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC))
|
||||||
|
|
||||||
typedef struct SWindowPosition {
|
|
||||||
int32_t pageId;
|
|
||||||
int32_t rowId;
|
|
||||||
} SWindowPosition;
|
|
||||||
|
|
||||||
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
static int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity);
|
||||||
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
static int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbTableMeta, size_t size,
|
||||||
const char* dbName);
|
const char* dbName);
|
||||||
|
|
||||||
|
static void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock);
|
||||||
|
static bool processBlockWithProbability(const SSampleExecInfo *pInfo);
|
||||||
|
|
||||||
|
bool processBlockWithProbability(const SSampleExecInfo *pInfo) {
|
||||||
|
#if 0
|
||||||
|
if (pInfo->sampleRatio == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t val = taosRandR((uint32_t*) &pInfo->seed);
|
||||||
|
return (val % ((uint32_t)(1/pInfo->sampleRatio))) == 0;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
static void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SWITCH_ORDER(pCtx[i].order);
|
SWITCH_ORDER(pCtx[i].order);
|
||||||
|
|
@ -160,8 +171,6 @@ static bool overlapWithTimeWindow(SInterval* pInterval, SDataBlockInfo* pBlockIn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock);
|
|
||||||
|
|
||||||
static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
|
||||||
uint32_t* status) {
|
uint32_t* status) {
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
@ -281,12 +290,9 @@ static void prepareForDescendingScan(STableScanInfo* pTableScanInfo, SqlFunction
|
||||||
STimeWindow* pTWindow = &pTableScanInfo->cond.twindows[i];
|
STimeWindow* pTWindow = &pTableScanInfo->cond.twindows[i];
|
||||||
TSWAP(pTWindow->skey, pTWindow->ekey);
|
TSWAP(pTWindow->skey, pTWindow->ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryTableDataCond* pCond = &pTableScanInfo->cond;
|
SQueryTableDataCond* pCond = &pTableScanInfo->cond;
|
||||||
taosqsort(pCond->twindows,
|
taosqsort(pCond->twindows, pCond->numOfTWindows, sizeof(STimeWindow), pCond, compareTimeWindow);
|
||||||
pCond->numOfTWindows,
|
|
||||||
sizeof(STimeWindow),
|
|
||||||
pCond,
|
|
||||||
compareTimeWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock) {
|
void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock) {
|
||||||
|
|
@ -329,6 +335,7 @@ void addTagPseudoColumnData(SReadHandle *pHandle, SExprInfo* pPseudoExpr, int32_
|
||||||
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
|
||||||
colDataAppend(pColInfoData, i, data, (data == NULL));
|
colDataAppend(pColInfoData, i, data, (data == NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && (pColInfoData->info.type != TSDB_DATA_TYPE_JSON) && p != NULL &&
|
if (data && (pColInfoData->info.type != TSDB_DATA_TYPE_JSON) && p != NULL &&
|
||||||
IS_VAR_DATA_TYPE(((const STagVal*)p)->type)) {
|
IS_VAR_DATA_TYPE(((const STagVal*)p)->type)) {
|
||||||
taosMemoryFree(data);
|
taosMemoryFree(data);
|
||||||
|
|
@ -366,6 +373,12 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process this data block based on the probabilities
|
||||||
|
bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample);
|
||||||
|
if (!processThisBlock) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &pBlock->info);
|
tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &pBlock->info);
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
|
|
@ -451,6 +464,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
STimeWindow* pWin = &pTableScanInfo->cond.twindows[i];
|
STimeWindow* pWin = &pTableScanInfo->cond.twindows[i];
|
||||||
qDebug("%s\t qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
|
qDebug("%s\t qrange:%" PRId64 "-%" PRId64, GET_TASKID(pTaskInfo), pWin->skey, pWin->ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (pTableScanInfo->scanTimes < total) {
|
while (pTableScanInfo->scanTimes < total) {
|
||||||
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
|
while (pTableScanInfo->curTWinIdx < pTableScanInfo->cond.numOfTWindows) {
|
||||||
SSDataBlock* p = doTableScanImpl(pOperator);
|
SSDataBlock* p = doTableScanImpl(pOperator);
|
||||||
|
|
@ -552,7 +566,9 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
|
|
||||||
pInfo->readHandle = *readHandle;
|
pInfo->readHandle = *readHandle;
|
||||||
pInfo->interval = extractIntervalInfo(pTableScanNode);
|
pInfo->interval = extractIntervalInfo(pTableScanNode);
|
||||||
pInfo->sampleRatio = pTableScanNode->ratio;
|
pInfo->sample.sampleRatio= pTableScanNode->ratio;
|
||||||
|
pInfo->sample.seed = taosGetTimestampSec();
|
||||||
|
|
||||||
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
pInfo->dataBlockLoadFlag = pTableScanNode->dataRequired;
|
||||||
pInfo->pResBlock = createResDataBlock(pDescNode);
|
pInfo->pResBlock = createResDataBlock(pDescNode);
|
||||||
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
pInfo->pFilterNode = pTableScanNode->scan.node.pConditions;
|
||||||
|
|
@ -586,13 +602,13 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
|
|
||||||
// for non-blocking operator, the open cost is always 0
|
// for non-blocking operator, the open cost is always 0
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
|
|
||||||
|
pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1429,7 +1445,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRetrieveMetaTableRsp* pTableRsp = pInfo->pRsp;
|
SRetrieveMetaTableRsp* pTableRsp = pInfo->pRsp;
|
||||||
setSDataBlockFromFetchRsp(pInfo->pRes, &pInfo->loadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
setDataBlockFromFetchRsp(pInfo->pRes, &pInfo->loadInfo, pTableRsp->numOfRows, pTableRsp->data,
|
||||||
pTableRsp->compLen, pOperator->numOfExprs, startTs, NULL, pInfo->scanCols);
|
pTableRsp->compLen, pOperator->numOfExprs, startTs, NULL, pInfo->scanCols);
|
||||||
|
|
||||||
// todo log the filter info
|
// todo log the filter info
|
||||||
|
|
@ -1503,34 +1519,38 @@ int32_t buildDbTableInfoBlock(const SSDataBlock* p, const SSysTableMeta* pSysDbT
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pResBlock, const SName* pName,
|
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, SExecTaskInfo* pTaskInfo) {
|
||||||
SNode* pCondition, SEpSet epset, SArray* colList,
|
|
||||||
SExecTaskInfo* pTaskInfo, bool showRewrite, int32_t accountId) {
|
|
||||||
SSysTableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SSysTableScanInfo));
|
SSysTableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SSysTableScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
taosMemoryFreeClear(pInfo);
|
goto _error;
|
||||||
taosMemoryFreeClear(pOperator);
|
|
||||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->accountId = accountId;
|
SScanPhysiNode* pScanNode = &pScanPhyNode->scan;
|
||||||
pInfo->showRewrite = showRewrite;
|
|
||||||
|
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
||||||
|
SSDataBlock* pResBlock = createResDataBlock(pDescNode);
|
||||||
|
|
||||||
|
int32_t num = 0;
|
||||||
|
SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
|
pInfo->accountId = pScanPhyNode->accountId;
|
||||||
|
pInfo->showRewrite = pScanPhyNode->showRewrite;
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = pResBlock;
|
||||||
pInfo->pCondition = pCondition;
|
pInfo->pCondition = pScanNode->node.pConditions;
|
||||||
pInfo->scanCols = colList;
|
pInfo->scanCols = colList;
|
||||||
|
|
||||||
initResultSizeInfo(pOperator, 4096);
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
|
||||||
tNameAssign(&pInfo->name, pName);
|
tNameAssign(&pInfo->name, &pScanNode->tableName);
|
||||||
const char* name = tNameGetTableName(&pInfo->name);
|
const char* name = tNameGetTableName(&pInfo->name);
|
||||||
|
|
||||||
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) {
|
||||||
pInfo->readHandle = *(SReadHandle*)readHandle;
|
pInfo->readHandle = *(SReadHandle*)readHandle;
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
} else {
|
} else {
|
||||||
tsem_init(&pInfo->ready, 0, 0);
|
tsem_init(&pInfo->ready, 0, 0);
|
||||||
pInfo->epSet = epset;
|
pInfo->epSet = pScanPhyNode->mgmtEpSet;
|
||||||
pInfo->readHandle = *(SReadHandle*)readHandle;
|
pInfo->readHandle = *(SReadHandle*)readHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1540,11 +1560,18 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSDataBlock* pRe
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->numOfExprs = pResBlock->info.numOfCols;
|
pOperator->numOfExprs = pResBlock->info.numOfCols;
|
||||||
pOperator->fpSet =
|
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, NULL, destroySysScanOperator, NULL, NULL, NULL);
|
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
|
pOperator->fpSet =
|
||||||
|
createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, NULL, destroySysScanOperator, NULL, NULL, NULL);
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
taosMemoryFreeClear(pInfo);
|
||||||
|
taosMemoryFreeClear(pOperator);
|
||||||
|
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
|
static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
|
||||||
|
|
@ -1699,18 +1726,24 @@ static void destroyTagScanOperatorInfo(void* param, int32_t numOfOutput) {
|
||||||
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
pInfo->pRes = blockDataDestroy(pInfo->pRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pExpr, int32_t numOfOutput,
|
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) {
|
||||||
SSDataBlock* pResBlock, SArray* pColMatchInfo, STableListInfo* pTableListInfo,
|
|
||||||
SExecTaskInfo* pTaskInfo) {
|
|
||||||
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo));
|
||||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||||
if (pInfo == NULL || pOperator == NULL) {
|
if (pInfo == NULL || pOperator == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDataBlockDescNode* pDescNode = pPhyNode->node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
|
int32_t numOfExprs = 0;
|
||||||
|
SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs);
|
||||||
|
|
||||||
|
int32_t num = 0;
|
||||||
|
SArray* colList = extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, pTaskInfo, COL_MATCH_FROM_COL_ID);
|
||||||
|
|
||||||
pInfo->pTableList = pTableListInfo;
|
pInfo->pTableList = pTableListInfo;
|
||||||
pInfo->pColMatchInfo = pColMatchInfo;
|
pInfo->pColMatchInfo = colList;
|
||||||
pInfo->pRes = pResBlock;
|
pInfo->pRes = createResDataBlock(pDescNode);;
|
||||||
pInfo->readHandle = *pReadHandle;
|
pInfo->readHandle = *pReadHandle;
|
||||||
pInfo->curPos = 0;
|
pInfo->curPos = 0;
|
||||||
pOperator->name = "TagScanOperator";
|
pOperator->name = "TagScanOperator";
|
||||||
|
|
@ -1718,8 +1751,8 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, SExprInfo* pE
|
||||||
pOperator->blocking = false;
|
pOperator->blocking = false;
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
pOperator->info = pInfo;
|
pOperator->info = pInfo;
|
||||||
pOperator->pExpr = pExpr;
|
pOperator->pExpr = pExprInfo;
|
||||||
pOperator->numOfExprs = numOfOutput;
|
pOperator->numOfExprs = numOfExprs;
|
||||||
pOperator->pTaskInfo = pTaskInfo;
|
pOperator->pTaskInfo = pTaskInfo;
|
||||||
|
|
||||||
initResultSizeInfo(pOperator, 4096);
|
initResultSizeInfo(pOperator, 4096);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "tdatablock.h"
|
#include "tdatablock.h"
|
||||||
#include "executorimpl.h"
|
#include "executorimpl.h"
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -401,9 +401,17 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
udf->bufSize = pFuncInfo->bufSize;
|
udf->bufSize = pFuncInfo->bufSize;
|
||||||
|
|
||||||
char path[PATH_MAX] = {0};
|
char path[PATH_MAX] = {0};
|
||||||
|
#ifdef WINDOWS
|
||||||
|
snprintf(path, sizeof(path), "%s%s.dll", TD_TMP_DIR_PATH, pFuncInfo->name);
|
||||||
|
#else
|
||||||
snprintf(path, sizeof(path), "%s/lib%s.so", TD_TMP_DIR_PATH, pFuncInfo->name);
|
snprintf(path, sizeof(path), "%s/lib%s.so", TD_TMP_DIR_PATH, pFuncInfo->name);
|
||||||
|
#endif
|
||||||
TdFilePtr file =
|
TdFilePtr file =
|
||||||
taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
||||||
|
if (file == NULL) {
|
||||||
|
fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno));
|
||||||
|
msgInfo->code = TSDB_CODE_FILE_CORRUPTED;
|
||||||
|
}
|
||||||
int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize);
|
int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize);
|
||||||
if (count != pFuncInfo->codeSize) {
|
if (count != pFuncInfo->codeSize) {
|
||||||
fnError("udfd write udf shared library failed");
|
fnError("udfd write udf shared library failed");
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@
|
||||||
#undef free
|
#undef free
|
||||||
#define free free
|
#define free free
|
||||||
|
|
||||||
int32_t udf1_init() {
|
DLL_EXPORT int32_t udf1_init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf1_destroy() {
|
DLL_EXPORT int32_t udf1_destroy() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
||||||
SUdfColumnMeta *meta = &resultCol->colMeta;
|
SUdfColumnMeta *meta = &resultCol->colMeta;
|
||||||
meta->bytes = 4;
|
meta->bytes = 4;
|
||||||
meta->type = TSDB_DATA_TYPE_INT;
|
meta->type = TSDB_DATA_TYPE_INT;
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,22 @@
|
||||||
#undef free
|
#undef free
|
||||||
#define free free
|
#define free free
|
||||||
|
|
||||||
int32_t udf2_init() {
|
DLL_EXPORT int32_t udf2_init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf2_destroy() {
|
DLL_EXPORT int32_t udf2_destroy() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf2_start(SUdfInterBuf *buf) {
|
DLL_EXPORT int32_t udf2_start(SUdfInterBuf *buf) {
|
||||||
*(int64_t*)(buf->buf) = 0;
|
*(int64_t*)(buf->buf) = 0;
|
||||||
buf->bufLen = sizeof(double);
|
buf->bufLen = sizeof(double);
|
||||||
buf->numOfResult = 0;
|
buf->numOfResult = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) {
|
||||||
double sumSquares = *(double*)interBuf->buf;
|
double sumSquares = *(double*)interBuf->buf;
|
||||||
int8_t numNotNull = 0;
|
int8_t numNotNull = 0;
|
||||||
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
for (int32_t i = 0; i < block->numOfCols; ++i) {
|
||||||
|
|
@ -71,7 +71,7 @@ int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInte
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t udf2_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) {
|
DLL_EXPORT int32_t udf2_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) {
|
||||||
if (buf->numOfResult == 0) {
|
if (buf->numOfResult == 0) {
|
||||||
resultData->numOfResult = 0;
|
resultData->numOfResult = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName), .colType = p->colType};
|
ICacheKey key = {.suid = p->suid, .colName = p->colName, .nColName = strlen(p->colName), .colType = p->colType};
|
||||||
int32_t sz = indexSerialCacheKey(&key, buf);
|
int32_t sz = indexSerialCacheKey(&key, buf);
|
||||||
indexDebug("suid: %" PRIu64 ", colName: %s, colType: %d", key.suid, key.colName, key.colType);
|
indexDebug("w suid: %" PRIu64 ", colName: %s, colType: %d", key.suid, key.colName, key.colType);
|
||||||
|
|
||||||
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
|
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
|
||||||
assert(*cache != NULL);
|
assert(*cache != NULL);
|
||||||
|
|
@ -330,7 +330,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
ICacheKey key = {
|
ICacheKey key = {
|
||||||
.suid = term->suid, .colName = term->colName, .nColName = strlen(term->colName), .colType = term->colType};
|
.suid = term->suid, .colName = term->colName, .nColName = strlen(term->colName), .colType = term->colType};
|
||||||
indexDebug("suid: %" PRIu64 ", colName: %s, colType: %d", key.suid, key.colName, key.colType);
|
indexDebug("r suid: %" PRIu64 ", colName: %s, colType: %d", key.suid, key.colName, key.colType);
|
||||||
int32_t sz = indexSerialCacheKey(&key, buf);
|
int32_t sz = indexSerialCacheKey(&key, buf);
|
||||||
|
|
||||||
taosThreadMutexLock(&sIdx->mtx);
|
taosThreadMutexLock(&sIdx->mtx);
|
||||||
|
|
|
||||||
|
|
@ -402,16 +402,16 @@ int32_t indexConvertDataToStr(void* src, int8_t type, void** dst) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
|
||||||
tlen = taosEncodeBinary(NULL, src, strlen(src));
|
tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src));
|
||||||
*dst = taosMemoryCalloc(1, tlen + 1);
|
*dst = taosMemoryCalloc(1, tlen + 1);
|
||||||
tlen = taosEncodeBinary(dst, src, strlen(src));
|
tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src));
|
||||||
*dst = (char*)*dst - tlen;
|
*dst = (char*)*dst - tlen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARBINARY:
|
case TSDB_DATA_TYPE_VARBINARY:
|
||||||
tlen = taosEncodeBinary(NULL, src, strlen(src));
|
tlen = taosEncodeBinary(NULL, varDataVal(src), varDataLen(src));
|
||||||
*dst = taosMemoryCalloc(1, tlen + 1);
|
*dst = taosMemoryCalloc(1, tlen + 1);
|
||||||
tlen = taosEncodeBinary(dst, src, strlen(src));
|
tlen = taosEncodeBinary(dst, varDataVal(src), varDataLen(src));
|
||||||
*dst = (char*)*dst - tlen;
|
*dst = (char*)*dst - tlen;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
||||||
dataLen = 0;
|
dataLen = 0;
|
||||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||||
dataLen = varDataTLen(pData + CHAR_BYTES);
|
dataLen = varDataTLen(pData + CHAR_BYTES);
|
||||||
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (*pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
dataLen = LONG_BYTES;
|
dataLen = LONG_BYTES;
|
||||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||||
dataLen = CHAR_BYTES;
|
dataLen = CHAR_BYTES;
|
||||||
|
|
@ -162,12 +162,27 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
|
SOperatorNode *nd = (SOperatorNode *)node;
|
||||||
|
assert(nodeType(node) == QUERY_NODE_OPERATOR);
|
||||||
|
SColumnNode *l = (SColumnNode *)nd->pLeft;
|
||||||
|
SValueNode * r = (SValueNode *)nd->pRight;
|
||||||
|
|
||||||
|
param->colId = l->colId;
|
||||||
|
param->colValType = l->node.resType.type;
|
||||||
|
memcpy(param->dbName, l->dbName, sizeof(l->dbName));
|
||||||
|
sprintf(param->colName, "%s_%s", l->colName, r->literal);
|
||||||
|
param->colValType = r->typeData;
|
||||||
|
return 0;
|
||||||
|
// memcpy(param->colName, l->colName, sizeof(l->colName));
|
||||||
|
}
|
||||||
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
switch (nodeType(node)) {
|
switch (nodeType(node)) {
|
||||||
case QUERY_NODE_VALUE: {
|
case QUERY_NODE_VALUE: {
|
||||||
SValueNode *vn = (SValueNode *)node;
|
SValueNode *vn = (SValueNode *)node;
|
||||||
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
||||||
param->colId = -1;
|
param->colId = -1;
|
||||||
|
param->colValType = (uint8_t)(vn->node.resType.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_COLUMN: {
|
case QUERY_NODE_COLUMN: {
|
||||||
|
|
@ -219,17 +234,31 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
||||||
indexError("invalid operation node, left: %p, rigth: %p", node->pLeft, node->pRight);
|
indexError("invalid operation node, left: %p, rigth: %p", node->pLeft, node->pRight);
|
||||||
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
if (node->opType == OP_TYPE_JSON_GET_VALUE || node->opType == OP_TYPE_JSON_CONTAINS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam));
|
||||||
if (NULL == paramList) {
|
if (NULL == paramList) {
|
||||||
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR) {
|
||||||
|
SNode *interNode = (node->pLeft);
|
||||||
|
SIF_ERR_JRET(sifInitJsonParam(interNode, ¶mList[0], ctx));
|
||||||
|
if (nParam > 1) {
|
||||||
|
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||||
|
}
|
||||||
|
paramList[0].colValType = TSDB_DATA_TYPE_JSON;
|
||||||
|
*params = paramList;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else {
|
||||||
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
||||||
if (nParam > 1) {
|
if (nParam > 1) {
|
||||||
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||||
}
|
}
|
||||||
*params = paramList;
|
*params = paramList;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
_return:
|
_return:
|
||||||
taosMemoryFree(paramList);
|
taosMemoryFree(paramList);
|
||||||
SIF_RET(code);
|
SIF_RET(code);
|
||||||
|
|
@ -306,25 +335,21 @@ static Filter sifGetFilterFunc(EIndexQueryType type, bool *reverse) {
|
||||||
}
|
}
|
||||||
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
||||||
SIndexMetaArg *arg = &output->arg;
|
SIndexMetaArg *arg = &output->arg;
|
||||||
#ifdef USE_INVERTED_INDEX
|
int ret = 0;
|
||||||
SIndexTerm *tm = indexTermCreate(arg->suid, DEFAULT, left->colValType, left->colName, strlen(left->colName),
|
|
||||||
|
EIndexQueryType qtype = 0;
|
||||||
|
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
||||||
|
if (left->colValType == TSDB_DATA_TYPE_JSON) {
|
||||||
|
SIndexTerm *tm = indexTermCreate(arg->suid, DEFAULT, right->colValType, left->colName, strlen(left->colName),
|
||||||
right->condValue, strlen(right->condValue));
|
right->condValue, strlen(right->condValue));
|
||||||
if (tm == NULL) {
|
if (tm == NULL) {
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
EIndexQueryType qtype = 0;
|
|
||||||
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
|
||||||
|
|
||||||
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST);
|
||||||
indexMultiTermQueryAdd(mtm, tm, qtype);
|
indexMultiTermQueryAdd(mtm, tm, qtype);
|
||||||
int ret = indexSearch(arg->metaHandle, mtm, output->result);
|
ret = tIndexJsonSearch(arg->ivtIdx, mtm, output->result);
|
||||||
indexDebug("index filter data size: %d", (int)taosArrayGetSize(output->result));
|
} else {
|
||||||
indexMultiTermQueryDestroy(mtm);
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
EIndexQueryType qtype = 0;
|
|
||||||
SIF_ERR_RET(sifGetFuncFromSql(operType, &qtype));
|
|
||||||
bool reverse;
|
bool reverse;
|
||||||
Filter filterFunc = sifGetFilterFunc(qtype, &reverse);
|
Filter filterFunc = sifGetFilterFunc(qtype, &reverse);
|
||||||
|
|
||||||
|
|
@ -335,10 +360,9 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
|
||||||
.reverse = reverse,
|
.reverse = reverse,
|
||||||
.filterFunc = filterFunc};
|
.filterFunc = filterFunc};
|
||||||
|
|
||||||
int ret = metaFilteTableIds(arg->metaEx, ¶m, output->result);
|
ret = metaFilteTableIds(arg->metaEx, ¶m, output->result);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifLessThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
static int32_t sifLessThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
|
@ -392,6 +416,14 @@ static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output
|
||||||
int id = OP_TYPE_NMATCH;
|
int id = OP_TYPE_NMATCH;
|
||||||
return sifDoIndex(left, right, id, output);
|
return sifDoIndex(left, right, id, output);
|
||||||
}
|
}
|
||||||
|
static int32_t sifJsonContains(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
|
// return 0
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int32_t sifJsonGetValue(SIFParam *left, SIFParam *rigth, SIFParam *output) {
|
||||||
|
// return 0
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
|
||||||
// add more except
|
// add more except
|
||||||
|
|
@ -445,6 +477,14 @@ static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *sta
|
||||||
*status = SFLT_NOT_INDEX;
|
*status = SFLT_NOT_INDEX;
|
||||||
*func = sifNotMatchFunc;
|
*func = sifNotMatchFunc;
|
||||||
return 0;
|
return 0;
|
||||||
|
case OP_TYPE_JSON_CONTAINS:
|
||||||
|
*status = SFLT_ACCURATE_INDEX;
|
||||||
|
*func = sifJsonContains;
|
||||||
|
return 0;
|
||||||
|
case OP_TYPE_JSON_GET_VALUE:
|
||||||
|
*status = SFLT_ACCURATE_INDEX;
|
||||||
|
*func = sifJsonGetValue;
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
*status = SFLT_NOT_INDEX;
|
*status = SFLT_NOT_INDEX;
|
||||||
*func = sifNullFunc;
|
*func = sifNullFunc;
|
||||||
|
|
@ -458,25 +498,24 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t nParam = sifGetOperParamNum(node->opType);
|
int32_t nParam = sifGetOperParamNum(node->opType);
|
||||||
if (nParam <= 1) {
|
if (nParam <= 1) {
|
||||||
SIF_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
}
|
||||||
|
if (node->opType == OP_TYPE_JSON_GET_VALUE || node->opType == OP_TYPE_JSON_CONTAINS) {
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SIFParam *params = NULL;
|
SIFParam *params = NULL;
|
||||||
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
|
||||||
|
|
||||||
|
SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx));
|
||||||
// ugly code, refactor later
|
// ugly code, refactor later
|
||||||
output->arg = ctx->arg;
|
output->arg = ctx->arg;
|
||||||
|
|
||||||
sif_func_t operFn = sifNullFunc;
|
sif_func_t operFn = sifNullFunc;
|
||||||
code = sifGetOperFn(node->opType, &operFn, &output->status);
|
code = sifGetOperFn(node->opType, &operFn, &output->status);
|
||||||
if (ctx->noExec) {
|
if (!ctx->noExec) {
|
||||||
SIF_RET(code);
|
code = operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
||||||
} else {
|
|
||||||
return operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output);
|
|
||||||
}
|
}
|
||||||
_return:
|
|
||||||
taosMemoryFree(params);
|
taosMemoryFree(params);
|
||||||
SIF_RET(code);
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *output) {
|
||||||
|
|
@ -573,7 +612,9 @@ EDealRes sifCalcWalker(SNode *node, void *context) {
|
||||||
if (QUERY_NODE_LOGIC_CONDITION == nodeType(node)) {
|
if (QUERY_NODE_LOGIC_CONDITION == nodeType(node)) {
|
||||||
return sifWalkLogic(node, ctx);
|
return sifWalkLogic(node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(node)) {
|
if (QUERY_NODE_OPERATOR == nodeType(node)) {
|
||||||
|
indexInfo("node type for index filter, type: %d", nodeType(node));
|
||||||
return sifWalkOper(node, ctx);
|
return sifWalkOper(node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -500,8 +500,13 @@ TEST_F(IndexTFileEnv, test_tfile_write) {
|
||||||
|
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
|
||||||
colVal.c_str(), colVal.size());
|
char buf[256] = {0};
|
||||||
|
int16_t sz = colVal.size();
|
||||||
|
memcpy(buf, (uint16_t*)&sz, 2);
|
||||||
|
memcpy(buf + 2, colVal.c_str(), colVal.size());
|
||||||
|
SIndexTerm* term =
|
||||||
|
indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), buf, sizeof(buf));
|
||||||
SIndexTermQuery query = {term, QUERY_TERM};
|
SIndexTermQuery query = {term, QUERY_TERM};
|
||||||
|
|
||||||
SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -564,6 +569,18 @@ class IndexCacheEnv : public ::testing::Test {
|
||||||
CacheObj* coj;
|
CacheObj* coj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SIndexTerm* indexTermCreateT(int64_t suid, SIndexOperOnColumn oper, uint8_t colType, const char* colName,
|
||||||
|
int32_t nColName, const char* colVal, int32_t nColVal) {
|
||||||
|
char buf[256] = {0};
|
||||||
|
int16_t sz = nColVal;
|
||||||
|
memcpy(buf, (uint16_t*)&sz, 2);
|
||||||
|
memcpy(buf + 2, colVal, nColVal);
|
||||||
|
if (colType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
return indexTermCreate(suid, oper, colType, colName, nColName, buf, sizeof(buf));
|
||||||
|
} else {
|
||||||
|
return indexTermCreate(suid, oper, colType, colName, nColName, colVal, nColVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
#define MAX_TERM_KEY_LEN 128
|
#define MAX_TERM_KEY_LEN 128
|
||||||
TEST_F(IndexCacheEnv, cache_test) {
|
TEST_F(IndexCacheEnv, cache_test) {
|
||||||
int version = 0;
|
int version = 0;
|
||||||
|
|
@ -574,7 +591,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
{
|
{
|
||||||
std::string colVal("v1");
|
std::string colVal("v1");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
|
|
@ -582,28 +599,28 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v2");
|
std::string colVal("v2");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
|
|
@ -612,14 +629,14 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
std::cout << "--------first----------" << std::endl;
|
std::cout << "--------first----------" << std::endl;
|
||||||
{
|
{
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, othColId, version++, suid++);
|
coj->Put(term, othColId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v4");
|
std::string colVal("v4");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, othColId, version++, suid++);
|
coj->Put(term, othColId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
|
|
@ -630,7 +647,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
std::string colVal("v4");
|
std::string colVal("v4");
|
||||||
for (size_t i = 0; i < 10; i++) {
|
for (size_t i = 0; i < 10; i++) {
|
||||||
colVal[colVal.size() - 1] = 'a' + i;
|
colVal[colVal.size() - 1] = 'a' + i;
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
coj->Put(term, colId, version++, suid++);
|
coj->Put(term, colId, version++, suid++);
|
||||||
indexTermDestroy(term);
|
indexTermDestroy(term);
|
||||||
|
|
@ -640,7 +657,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
// begin query
|
// begin query
|
||||||
{
|
{
|
||||||
std::string colVal("v3");
|
std::string colVal("v3");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexTermQuery query = {term, QUERY_TERM};
|
SIndexTermQuery query = {term, QUERY_TERM};
|
||||||
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
||||||
|
|
@ -655,7 +672,7 @@ TEST_F(IndexCacheEnv, cache_test) {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colVal("v2");
|
std::string colVal("v2");
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexTermQuery query = {term, QUERY_TERM};
|
SIndexTermQuery query = {term, QUERY_TERM};
|
||||||
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid));
|
||||||
|
|
@ -690,7 +707,7 @@ class IndexObj {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
void Del(const std::string& colName, const std::string& colVal, uint64_t uid) {
|
void Del(const std::string& colName, const std::string& colVal, uint64_t uid) {
|
||||||
SIndexTerm* term = indexTermCreate(0, DEL_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, DEL_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -699,7 +716,7 @@ class IndexObj {
|
||||||
}
|
}
|
||||||
int WriteMillonData(const std::string& colName, const std::string& colVal = "Hello world",
|
int WriteMillonData(const std::string& colName, const std::string& colVal = "Hello world",
|
||||||
size_t numOfTable = 100 * 10000) {
|
size_t numOfTable = 100 * 10000) {
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -721,7 +738,7 @@ class IndexObj {
|
||||||
// opt
|
// opt
|
||||||
tColVal[taosRand() % colValSize] = 'a' + k % 26;
|
tColVal[taosRand() % colValSize] = 'a' + k % 26;
|
||||||
}
|
}
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
tColVal.c_str(), tColVal.size());
|
tColVal.c_str(), tColVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -757,7 +774,7 @@ class IndexObj {
|
||||||
|
|
||||||
int SearchOne(const std::string& colName, const std::string& colVal) {
|
int SearchOne(const std::string& colName, const std::string& colVal) {
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
||||||
|
|
||||||
|
|
@ -779,7 +796,7 @@ class IndexObj {
|
||||||
}
|
}
|
||||||
int SearchOneTarget(const std::string& colName, const std::string& colVal, uint64_t val) {
|
int SearchOneTarget(const std::string& colName, const std::string& colVal, uint64_t val) {
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
||||||
|
|
||||||
|
|
@ -804,7 +821,7 @@ class IndexObj {
|
||||||
|
|
||||||
void PutOne(const std::string& colName, const std::string& colVal) {
|
void PutOne(const std::string& colName, const std::string& colVal) {
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
Put(terms, 10);
|
Put(terms, 10);
|
||||||
|
|
@ -812,7 +829,7 @@ class IndexObj {
|
||||||
}
|
}
|
||||||
void PutOneTarge(const std::string& colName, const std::string& colVal, uint64_t val) {
|
void PutOneTarge(const std::string& colName, const std::string& colVal, uint64_t val) {
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
Put(terms, val);
|
Put(terms, val);
|
||||||
|
|
@ -858,7 +875,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
|
||||||
{
|
{
|
||||||
std::string colName("tag1"), colVal("Hello");
|
std::string colName("tag1"), colVal("Hello");
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -873,7 +890,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
|
||||||
size_t size = 200;
|
size_t size = 200;
|
||||||
std::string colName("tag1"), colVal("hello");
|
std::string colName("tag1"), colVal("hello");
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -888,7 +905,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
|
||||||
size_t size = 200;
|
size_t size = 200;
|
||||||
std::string colName("tag1"), colVal("Hello");
|
std::string colName("tag1"), colVal("Hello");
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
@ -903,7 +920,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
|
||||||
{
|
{
|
||||||
std::string colName("tag1"), colVal("Hello");
|
std::string colName("tag1"), colVal("Hello");
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
indexMultiTermQueryAdd(mq, term, QUERY_TERM);
|
||||||
|
|
||||||
|
|
@ -926,7 +943,7 @@ TEST_F(IndexEnv2, testEmptyIndexOpen) {
|
||||||
{
|
{
|
||||||
std::string colName("tag1"), colVal("Hello");
|
std::string colName("tag1"), colVal("Hello");
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,18 @@
|
||||||
static std::string dir = TD_TMP_DIR_PATH "json";
|
static std::string dir = TD_TMP_DIR_PATH "json";
|
||||||
static std::string logDir = TD_TMP_DIR_PATH "log";
|
static std::string logDir = TD_TMP_DIR_PATH "log";
|
||||||
|
|
||||||
|
SIndexTerm* indexTermCreateT(int64_t suid, SIndexOperOnColumn oper, uint8_t colType, const char* colName,
|
||||||
|
int32_t nColName, const char* colVal, int32_t nColVal) {
|
||||||
|
char buf[256] = {0};
|
||||||
|
int16_t sz = nColVal;
|
||||||
|
memcpy(buf, (uint16_t*)&sz, 2);
|
||||||
|
memcpy(buf + 2, colVal, nColVal);
|
||||||
|
if (colType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
return indexTermCreate(suid, oper, colType, colName, nColName, buf, sizeof(buf));
|
||||||
|
} else {
|
||||||
|
return indexTermCreate(suid, oper, colType, colName, nColName, colVal, nColVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
static void initLog() {
|
static void initLog() {
|
||||||
const char* defaultLogFileNamePrefix = "taoslog";
|
const char* defaultLogFileNamePrefix = "taoslog";
|
||||||
const int32_t maxLogFileNum = 10;
|
const int32_t maxLogFileNum = 10;
|
||||||
|
|
@ -59,8 +71,8 @@ class JsonEnv : public ::testing::Test {
|
||||||
|
|
||||||
static void WriteData(SIndexJson* index, const std::string& colName, int8_t dtype, void* data, int dlen, int tableId,
|
static void WriteData(SIndexJson* index, const std::string& colName, int8_t dtype, void* data, int dlen, int tableId,
|
||||||
int8_t operType = ADD_VALUE) {
|
int8_t operType = ADD_VALUE) {
|
||||||
SIndexTerm* term =
|
SIndexTerm* term = indexTermCreateT(1, (SIndexOperOnColumn)operType, dtype, colName.c_str(), colName.size(),
|
||||||
indexTermCreate(1, (SIndexOperOnColumn)operType, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
(const char*)data, dlen);
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, (int64_t)tableId);
|
tIndexJsonPut(index, terms, (int64_t)tableId);
|
||||||
|
|
@ -70,8 +82,8 @@ static void WriteData(SIndexJson* index, const std::string& colName, int8_t dtyp
|
||||||
|
|
||||||
static void delData(SIndexJson* index, const std::string& colName, int8_t dtype, void* data, int dlen, int tableId,
|
static void delData(SIndexJson* index, const std::string& colName, int8_t dtype, void* data, int dlen, int tableId,
|
||||||
int8_t operType = DEL_VALUE) {
|
int8_t operType = DEL_VALUE) {
|
||||||
SIndexTerm* term =
|
SIndexTerm* term = indexTermCreateT(1, (SIndexOperOnColumn)operType, dtype, colName.c_str(), colName.size(),
|
||||||
indexTermCreate(1, (SIndexOperOnColumn)operType, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
(const char*)data, dlen);
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, (int64_t)tableId);
|
tIndexJsonPut(index, terms, (int64_t)tableId);
|
||||||
|
|
@ -83,7 +95,7 @@ static void Search(SIndexJson* index, const std::string& colNam, int8_t dtype, v
|
||||||
std::string colName(colNam);
|
std::string colName(colNam);
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, dtype, colName.c_str(), colName.size(), (const char*)data, dlen);
|
||||||
|
|
||||||
SArray* res = taosArrayInit(1, sizeof(uint64_t));
|
SArray* res = taosArrayInit(1, sizeof(uint64_t));
|
||||||
indexMultiTermQueryAdd(mq, q, (EIndexQueryType)filterType);
|
indexMultiTermQueryAdd(mq, q, (EIndexQueryType)filterType);
|
||||||
|
|
@ -95,7 +107,7 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -108,7 +120,7 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
{
|
{
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
std::string colVal("ab1");
|
std::string colVal("ab1");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -121,7 +133,7 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
{
|
{
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
std::string colVal("123");
|
std::string colVal("123");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -136,7 +148,7 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -150,7 +162,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -165,7 +177,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
std::string colVal("abxxxxxxxxxxxx");
|
std::string colVal("abxxxxxxxxxxxx");
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
colVal[i % colVal.size()] = '0' + i % 128;
|
colVal[i % colVal.size()] = '0' + i % 128;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -179,7 +191,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
{
|
{
|
||||||
std::string colName("voltagefdadfa");
|
std::string colName("voltagefdadfa");
|
||||||
std::string colVal("abxxxxxxxxxxxx");
|
std::string colVal("abxxxxxxxxxxxx");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -194,7 +206,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -209,7 +221,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -224,7 +236,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -241,7 +253,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
int val = 10;
|
int val = 10;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -254,7 +266,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
{
|
{
|
||||||
std::string colName("test2");
|
std::string colName("test2");
|
||||||
int val = 20;
|
int val = 20;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -267,7 +279,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
int val = 15;
|
int val = 15;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -280,7 +292,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
{
|
{
|
||||||
std::string colName("test2");
|
std::string colName("test2");
|
||||||
const char* val = "test";
|
const char* val = "test";
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
(const char*)val, strlen(val));
|
(const char*)val, strlen(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -294,7 +306,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
int val = 15;
|
int val = 15;
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -308,7 +320,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
int val = 15;
|
int val = 15;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -323,7 +335,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
;
|
;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(int));
|
(const char*)&val, sizeof(int));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -338,7 +350,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -353,7 +365,7 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -368,7 +380,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
int val = 10;
|
int val = 10;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -381,7 +393,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("xxxxxxxxxxxxxxxxxxx");
|
std::string colVal("xxxxxxxxxxxxxxxxxxx");
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -396,7 +408,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -410,7 +422,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(int));
|
(const char*)&val, sizeof(int));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -425,7 +437,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -439,7 +451,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -453,7 +465,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
int val = 10;
|
int val = 10;
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -466,7 +478,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
std::string colName("other_column");
|
std::string colName("other_column");
|
||||||
int val = 100;
|
int val = 100;
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -482,7 +494,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
@ -494,7 +506,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
int val = 15;
|
int val = 15;
|
||||||
SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
|
@ -510,7 +522,7 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
|
|
||||||
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST);
|
||||||
SIndexTerm* q = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
SIndexTerm* q = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
(const char*)&val, sizeof(val));
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,8 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
CLONE_NODE_LIST_FIELD(pScanCols);
|
CLONE_NODE_LIST_FIELD(pScanCols);
|
||||||
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
CLONE_NODE_LIST_FIELD(pScanPseudoCols);
|
||||||
CLONE_OBJECT_FIELD(pMeta, tableMetaClone);
|
COPY_SCALAR_FIELD(tableType);
|
||||||
|
COPY_SCALAR_FIELD(tableId);
|
||||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||||
COPY_SCALAR_FIELD(scanType);
|
COPY_SCALAR_FIELD(scanType);
|
||||||
COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2);
|
COPY_OBJECT_FIELD(scanSeq[0], sizeof(uint8_t) * 2);
|
||||||
|
|
@ -365,9 +366,15 @@ static SNode* logicProjectCopy(const SProjectLogicNode* pSrc, SProjectLogicNode*
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* logicVnodeModifCopy(const SVnodeModifLogicNode* pSrc, SVnodeModifLogicNode* pDst) {
|
static SNode* logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModifyLogicNode* pDst) {
|
||||||
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
COPY_BASE_OBJECT_FIELD(node, logicNodeCopy);
|
||||||
|
COPY_SCALAR_FIELD(modifyType);
|
||||||
COPY_SCALAR_FIELD(msgType);
|
COPY_SCALAR_FIELD(msgType);
|
||||||
|
CLONE_NODE_FIELD(pModifyRows);
|
||||||
|
COPY_SCALAR_FIELD(tableId);
|
||||||
|
COPY_SCALAR_FIELD(tableType);
|
||||||
|
COPY_CHAR_ARRAY_FIELD(tableFName);
|
||||||
|
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -400,7 +407,7 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
|
||||||
COPY_SCALAR_FIELD(triggerType);
|
COPY_SCALAR_FIELD(triggerType);
|
||||||
COPY_SCALAR_FIELD(watermark);
|
COPY_SCALAR_FIELD(watermark);
|
||||||
COPY_SCALAR_FIELD(filesFactor);
|
COPY_SCALAR_FIELD(filesFactor);
|
||||||
COPY_SCALAR_FIELD(stmInterAlgo);
|
COPY_SCALAR_FIELD(intervalAlgo);
|
||||||
return (SNode*)pDst;
|
return (SNode*)pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,8 +555,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
|
||||||
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
return logicAggCopy((const SAggLogicNode*)pNode, (SAggLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
return logicProjectCopy((const SProjectLogicNode*)pNode, (SProjectLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
return logicVnodeModifCopy((const SVnodeModifLogicNode*)pNode, (SVnodeModifLogicNode*)pDst);
|
return logicVnodeModifCopy((const SVnodeModifyLogicNode*)pNode, (SVnodeModifyLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
return logicExchangeCopy((const SExchangeLogicNode*)pNode, (SExchangeLogicNode*)pDst);
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
|
|
|
||||||
|
|
@ -188,8 +188,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "LogicAgg";
|
return "LogicAgg";
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return "LogicProject";
|
return "LogicProject";
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
return "LogicVnodeModif";
|
return "LogicVnodeModify";
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return "LogicExchange";
|
return "LogicExchange";
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
|
|
@ -230,8 +230,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "PhysiMerge";
|
return "PhysiMerge";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return "PhysiSort";
|
return "PhysiSort";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
return "PhysiInterval";
|
return "PhysiHashInterval";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
return "PhysiStreamInterval";
|
return "PhysiStreamInterval";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||||
|
|
@ -256,6 +256,8 @@ const char* nodesNodeName(ENodeType type) {
|
||||||
return "PhysiDispatch";
|
return "PhysiDispatch";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
return "PhysiInsert";
|
return "PhysiInsert";
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_DELETE:
|
||||||
|
return "PhysiDelete";
|
||||||
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
||||||
return "PhysiSubplan";
|
return "PhysiSubplan";
|
||||||
case QUERY_NODE_PHYSICAL_PLAN:
|
case QUERY_NODE_PHYSICAL_PLAN:
|
||||||
|
|
@ -508,8 +510,8 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
|
||||||
|
|
||||||
static const char* jkScanLogicPlanScanCols = "ScanCols";
|
static const char* jkScanLogicPlanScanCols = "ScanCols";
|
||||||
static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
|
static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
|
||||||
static const char* jkScanLogicPlanTableMetaSize = "TableMetaSize";
|
static const char* jkScanLogicPlanTableId = "TableId";
|
||||||
static const char* jkScanLogicPlanTableMeta = "TableMeta";
|
static const char* jkScanLogicPlanTableType = "TableType";
|
||||||
static const char* jkScanLogicPlanTagCond = "TagCond";
|
static const char* jkScanLogicPlanTagCond = "TagCond";
|
||||||
|
|
||||||
static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
|
@ -523,10 +525,10 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
code = nodeListToJson(pJson, jkScanLogicPlanScanPseudoCols, pNode->pScanPseudoCols);
|
code = nodeListToJson(pJson, jkScanLogicPlanScanPseudoCols, pNode->pScanPseudoCols);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableMetaSize, TABLE_META_SIZE(pNode->pMeta));
|
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableId, pNode->tableId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkScanLogicPlanTableMeta, tableMetaToJson, pNode->pMeta);
|
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableType, pNode->tableType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond);
|
code = tjsonAddObject(pJson, jkScanLogicPlanTagCond, nodeToJson, pNode->pTagCond);
|
||||||
|
|
@ -547,10 +549,10 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
|
||||||
code = jsonToNodeList(pJson, jkScanLogicPlanScanPseudoCols, &pNode->pScanPseudoCols);
|
code = jsonToNodeList(pJson, jkScanLogicPlanScanPseudoCols, &pNode->pScanPseudoCols);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkScanLogicPlanTableMetaSize, &objSize);
|
code = tjsonGetUBigIntValue(pJson, jkScanLogicPlanTableId, &pNode->tableId);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonMakeObject(pJson, jkScanLogicPlanTableMeta, jsonToTableMeta, (void**)&pNode->pMeta, objSize);
|
code = tjsonGetTinyIntValue(pJson, jkScanLogicPlanTableType, &pNode->tableType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond);
|
code = jsonToNodeObject(pJson, jkScanLogicPlanTagCond, &pNode->pTagCond);
|
||||||
|
|
@ -582,7 +584,7 @@ static int32_t logicProjectNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit);
|
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSlimit, pNode->slimit);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkScanLogicPlanTableMetaSize, pNode->soffset);
|
code = tjsonAddIntegerToObject(pJson, jkProjectLogicPlanSoffset, pNode->soffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -605,7 +607,45 @@ static int32_t jsonToLogicProjectNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit);
|
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSlimit, &pNode->slimit);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkScanLogicPlanTableMetaSize, &pNode->soffset);
|
code = tjsonGetBigIntValue(pJson, jkProjectLogicPlanSoffset, &pNode->soffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* jkVnodeModifyLogicPlanModifyType = "ModifyType";
|
||||||
|
static const char* jkVnodeModifyLogicPlanMsgType = "MsgType";
|
||||||
|
static const char* jkVnodeModifyLogicPlanModifyRows = "ModifyRows";
|
||||||
|
|
||||||
|
static int32_t logicVnodeModifyNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SVnodeModifyLogicNode* pNode = (const SVnodeModifyLogicNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = logicPlanNodeToJson(pObj, pJson);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkVnodeModifyLogicPlanModifyType, pNode->modifyType);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkVnodeModifyLogicPlanMsgType, pNode->msgType);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkVnodeModifyLogicPlanModifyRows, nodeToJson, pNode->pModifyRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToLogicVnodeModifyNode(const SJson* pJson, void* pObj) {
|
||||||
|
SVnodeModifyLogicNode* pNode = (SVnodeModifyLogicNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = jsonToLogicPlanNode(pJson, pObj);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
tjsonGetNumberValue(pJson, jkVnodeModifyLogicPlanModifyType, pNode->modifyType, code);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetIntValue(pJson, jkVnodeModifyLogicPlanMsgType, &pNode->msgType);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkVnodeModifyLogicPlanModifyRows, &pNode->pModifyRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -2014,6 +2054,58 @@ static int32_t physiDispatchNodeToJson(const void* pObj, SJson* pJson) { return
|
||||||
|
|
||||||
static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) { return jsonToPhysicDataSinkNode(pJson, pObj); }
|
static int32_t jsonToPhysiDispatchNode(const SJson* pJson, void* pObj) { return jsonToPhysicDataSinkNode(pJson, pObj); }
|
||||||
|
|
||||||
|
static const char* jkDeletePhysiPlanTableId = "TableId";
|
||||||
|
static const char* jkDeletePhysiPlanTableType = "TableType";
|
||||||
|
static const char* jkDeletePhysiPlanTableFName = "TableFName";
|
||||||
|
static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey";
|
||||||
|
static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey";
|
||||||
|
|
||||||
|
static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SDataDeleterNode* pNode = (const SDataDeleterNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = physicDataSinkNodeToJson(pObj, pJson);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanTableId, pNode->tableId);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanTableType, pNode->tableType);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, pNode->deleteTimeRange.skey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeEndKey, pNode->deleteTimeRange.ekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToPhysiDeleteNode(const SJson* pJson, void* pObj) {
|
||||||
|
SDataDeleterNode* pNode = (SDataDeleterNode*)pObj;
|
||||||
|
|
||||||
|
int32_t code = jsonToPhysicDataSinkNode(pJson, pObj);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetUBigIntValue(pJson, jkDeletePhysiPlanTableId, &pNode->tableId);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetTinyIntValue(pJson, jkDeletePhysiPlanTableType, &pNode->tableType);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, &pNode->deleteTimeRange.skey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeEndKey, &pNode->deleteTimeRange.ekey);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkQueryNodeAddrId = "Id";
|
static const char* jkQueryNodeAddrId = "Id";
|
||||||
static const char* jkQueryNodeAddrInUse = "InUse";
|
static const char* jkQueryNodeAddrInUse = "InUse";
|
||||||
static const char* jkQueryNodeAddrNumOfEps = "NumOfEps";
|
static const char* jkQueryNodeAddrNumOfEps = "NumOfEps";
|
||||||
|
|
@ -3581,6 +3673,73 @@ static int32_t jsonToCreateTopicStmt(const SJson* pJson, void* pObj) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkDeleteStmtFromTable = "FromTable";
|
||||||
|
static const char* jkDeleteStmtWhere = "Where";
|
||||||
|
static const char* jkDeleteStmtCountFunc = "CountFunc";
|
||||||
|
static const char* jkDeleteStmtTagIndexCond = "TagIndexCond";
|
||||||
|
static const char* jkDeleteStmtTimeRangeStartKey = "TimeRangeStartKey";
|
||||||
|
static const char* jkDeleteStmtTimeRangeEndKey = "TimeRangeEndKey";
|
||||||
|
static const char* jkDeleteStmtPrecision = "Precision";
|
||||||
|
static const char* jkDeleteStmtDeleteZeroRows = "DeleteZeroRows";
|
||||||
|
|
||||||
|
static int32_t deleteStmtToJson(const void* pObj, SJson* pJson) {
|
||||||
|
const SDeleteStmt* pNode = (const SDeleteStmt*)pObj;
|
||||||
|
|
||||||
|
int32_t code = tjsonAddObject(pJson, jkDeleteStmtFromTable, nodeToJson, pNode->pFromTable);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkDeleteStmtWhere, nodeToJson, pNode->pWhere);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkDeleteStmtCountFunc, nodeToJson, pNode->pCountFunc);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddObject(pJson, jkDeleteStmtTagIndexCond, nodeToJson, pNode->pTagIndexCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeleteStmtTimeRangeStartKey, pNode->timeRange.skey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeleteStmtTimeRangeEndKey, pNode->timeRange.ekey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddIntegerToObject(pJson, jkDeleteStmtPrecision, pNode->precision);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddBoolToObject(pJson, jkDeleteStmtDeleteZeroRows, pNode->deleteZeroRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t jsonToDeleteStmt(const SJson* pJson, void* pObj) {
|
||||||
|
SDeleteStmt* pNode = (SDeleteStmt*)pObj;
|
||||||
|
|
||||||
|
int32_t code = jsonToNodeObject(pJson, jkDeleteStmtFromTable, &pNode->pFromTable);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkDeleteStmtWhere, &pNode->pWhere);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkDeleteStmtCountFunc, &pNode->pCountFunc);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = jsonToNodeObject(pJson, jkDeleteStmtTagIndexCond, &pNode->pTagIndexCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkDeleteStmtTimeRangeStartKey, &pNode->timeRange.skey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBigIntValue(pJson, jkDeleteStmtTimeRangeEndKey, &pNode->timeRange.ekey);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetUTinyIntValue(pJson, jkDeleteStmtPrecision, &pNode->precision);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetBoolValue(pJson, jkDeleteStmtDeleteZeroRows, &pNode->deleteZeroRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
switch (nodeType(pObj)) {
|
switch (nodeType(pObj)) {
|
||||||
case QUERY_NODE_COLUMN:
|
case QUERY_NODE_COLUMN:
|
||||||
|
|
@ -3653,6 +3812,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
break;
|
break;
|
||||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||||
return createTopicStmtToJson(pObj, pJson);
|
return createTopicStmtToJson(pObj, pJson);
|
||||||
|
case QUERY_NODE_DELETE_STMT:
|
||||||
|
return deleteStmtToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return logicScanNodeToJson(pObj, pJson);
|
return logicScanNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
case QUERY_NODE_LOGIC_PLAN_JOIN:
|
||||||
|
|
@ -3661,8 +3822,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return logicAggNodeToJson(pObj, pJson);
|
return logicAggNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return logicProjectNodeToJson(pObj, pJson);
|
return logicProjectNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
break;
|
return logicVnodeModifyNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return logicExchangeNodeToJson(pObj, pJson);
|
return logicExchangeNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
|
|
@ -3701,7 +3862,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return physiMergeNodeToJson(pObj, pJson);
|
return physiMergeNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return physiSortNodeToJson(pObj, pJson);
|
return physiSortNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
||||||
|
|
@ -3722,6 +3883,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
return physiDispatchNodeToJson(pObj, pJson);
|
return physiDispatchNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_DELETE:
|
||||||
|
return physiDeleteNodeToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
||||||
return subplanToJson(pObj, pJson);
|
return subplanToJson(pObj, pJson);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN:
|
case QUERY_NODE_PHYSICAL_PLAN:
|
||||||
|
|
@ -3785,10 +3948,14 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToAlterDnodeStmt(pJson, pObj);
|
return jsonToAlterDnodeStmt(pJson, pObj);
|
||||||
case QUERY_NODE_CREATE_TOPIC_STMT:
|
case QUERY_NODE_CREATE_TOPIC_STMT:
|
||||||
return jsonToCreateTopicStmt(pJson, pObj);
|
return jsonToCreateTopicStmt(pJson, pObj);
|
||||||
|
case QUERY_NODE_DELETE_STMT:
|
||||||
|
return jsonToDeleteStmt(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
return jsonToLogicScanNode(pJson, pObj);
|
return jsonToLogicScanNode(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return jsonToLogicProjectNode(pJson, pObj);
|
return jsonToLogicProjectNode(pJson, pObj);
|
||||||
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
|
return jsonToLogicVnodeModifyNode(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return jsonToLogicExchangeNode(pJson, pObj);
|
return jsonToLogicExchangeNode(pJson, pObj);
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
|
|
@ -3827,7 +3994,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToPhysiMergeNode(pJson, pObj);
|
return jsonToPhysiMergeNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return jsonToPhysiSortNode(pJson, pObj);
|
return jsonToPhysiSortNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
|
||||||
|
|
@ -3846,6 +4013,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
|
||||||
return jsonToPhysiIndefRowsFuncNode(pJson, pObj);
|
return jsonToPhysiIndefRowsFuncNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
|
||||||
return jsonToPhysiDispatchNode(pJson, pObj);
|
return jsonToPhysiDispatchNode(pJson, pObj);
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_DELETE:
|
||||||
|
return jsonToPhysiDeleteNode(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
||||||
return jsonToSubplan(pJson, pObj);
|
return jsonToSubplan(pJson, pObj);
|
||||||
case QUERY_NODE_PHYSICAL_PLAN:
|
case QUERY_NODE_PHYSICAL_PLAN:
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,7 @@ static EDealRes dispatchPhysiPlan(SNode* pNode, ETraversalOrder order, FNodeWalk
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext);
|
res = walkWindowPhysi((SWinodwPhysiNode*)pNode, order, walker, pContext);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -218,8 +218,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SAggLogicNode));
|
return makeNode(type, sizeof(SAggLogicNode));
|
||||||
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
case QUERY_NODE_LOGIC_PLAN_PROJECT:
|
||||||
return makeNode(type, sizeof(SProjectLogicNode));
|
return makeNode(type, sizeof(SProjectLogicNode));
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF:
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY:
|
||||||
return makeNode(type, sizeof(SVnodeModifLogicNode));
|
return makeNode(type, sizeof(SVnodeModifyLogicNode));
|
||||||
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
case QUERY_NODE_LOGIC_PLAN_EXCHANGE:
|
||||||
return makeNode(type, sizeof(SExchangeLogicNode));
|
return makeNode(type, sizeof(SExchangeLogicNode));
|
||||||
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
case QUERY_NODE_LOGIC_PLAN_MERGE:
|
||||||
|
|
@ -260,8 +260,10 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SMergePhysiNode));
|
return makeNode(type, sizeof(SMergePhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
case QUERY_NODE_PHYSICAL_PLAN_SORT:
|
||||||
return makeNode(type, sizeof(SSortPhysiNode));
|
return makeNode(type, sizeof(SSortPhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
return makeNode(type, sizeof(SIntervalPhysiNode));
|
return makeNode(type, sizeof(SIntervalPhysiNode));
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_SORT_MERGE_INTERVAL:
|
||||||
|
return makeNode(type, sizeof(SSortMergeIntervalPhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
return makeNode(type, sizeof(SStreamIntervalPhysiNode));
|
return makeNode(type, sizeof(SStreamIntervalPhysiNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
|
||||||
|
|
@ -286,6 +288,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
|
||||||
return makeNode(type, sizeof(SDataDispatcherNode));
|
return makeNode(type, sizeof(SDataDispatcherNode));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
case QUERY_NODE_PHYSICAL_PLAN_INSERT:
|
||||||
return makeNode(type, sizeof(SDataInserterNode));
|
return makeNode(type, sizeof(SDataInserterNode));
|
||||||
|
case QUERY_NODE_PHYSICAL_PLAN_DELETE:
|
||||||
|
return makeNode(type, sizeof(SDataDeleterNode));
|
||||||
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
case QUERY_NODE_PHYSICAL_SUBPLAN:
|
||||||
return makeNode(type, sizeof(SSubplan));
|
return makeNode(type, sizeof(SSubplan));
|
||||||
case QUERY_NODE_PHYSICAL_PLAN:
|
case QUERY_NODE_PHYSICAL_PLAN:
|
||||||
|
|
@ -565,7 +569,6 @@ void nodesDestroyNode(SNodeptr pNode) {
|
||||||
SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode;
|
SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode;
|
||||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||||
nodesDestroyList(pLogicNode->pScanCols);
|
nodesDestroyList(pLogicNode->pScanCols);
|
||||||
taosMemoryFreeClear(pLogicNode->pMeta);
|
|
||||||
taosMemoryFreeClear(pLogicNode->pVgroupList);
|
taosMemoryFreeClear(pLogicNode->pVgroupList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -588,8 +591,8 @@ void nodesDestroyNode(SNodeptr pNode) {
|
||||||
nodesDestroyList(pLogicNode->pProjections);
|
nodesDestroyList(pLogicNode->pProjections);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF: {
|
case QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY: {
|
||||||
SVnodeModifLogicNode* pLogicNode = (SVnodeModifLogicNode*)pNode;
|
SVnodeModifyLogicNode* pLogicNode = (SVnodeModifyLogicNode*)pNode;
|
||||||
destroyLogicNode((SLogicNode*)pLogicNode);
|
destroyLogicNode((SLogicNode*)pLogicNode);
|
||||||
destroyVgDataBlockArray(pLogicNode->pDataBlocks);
|
destroyVgDataBlockArray(pLogicNode->pDataBlocks);
|
||||||
// pVgDataBlocks is weak reference
|
// pVgDataBlocks is weak reference
|
||||||
|
|
@ -677,7 +680,7 @@ void nodesDestroyNode(SNodeptr pNode) {
|
||||||
nodesDestroyNode(pPhyNode->pSortKeys);
|
nodesDestroyNode(pPhyNode->pSortKeys);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
|
||||||
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
|
||||||
destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode);
|
destroyWinodwPhysiNode((SWinodwPhysiNode*)pNode);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1070,7 +1073,7 @@ char* nodesGetStrValueFromNode(SValueNode* pNode) {
|
||||||
bool nodesIsExprNode(const SNode* pNode) {
|
bool nodesIsExprNode(const SNode* pNode) {
|
||||||
ENodeType type = nodeType(pNode);
|
ENodeType type = nodeType(pNode);
|
||||||
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type ||
|
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type ||
|
||||||
QUERY_NODE_FUNCTION == type);
|
QUERY_NODE_FUNCTION == type || QUERY_NODE_LOGIC_CONDITION == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
||||||
|
|
@ -1097,7 +1100,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
|
||||||
case OP_TYPE_SUB:
|
case OP_TYPE_SUB:
|
||||||
case OP_TYPE_MULTI:
|
case OP_TYPE_MULTI:
|
||||||
case OP_TYPE_DIV:
|
case OP_TYPE_DIV:
|
||||||
case OP_TYPE_MOD:
|
case OP_TYPE_REM:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t translate(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||||
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery);
|
||||||
int32_t isNotSchemalessDb(SParseContext* pContext, char *dbName);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@ expression(A) ::= expression(B) NK_SLASH expression(C).
|
||||||
expression(A) ::= expression(B) NK_REM expression(C). {
|
expression(A) ::= expression(B) NK_REM expression(C). {
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||||
}
|
}
|
||||||
expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). {
|
expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). {
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||||
|
|
|
||||||
|
|
@ -1489,11 +1489,27 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNode* createCountFuncForDelete(SAstCreateContext* pCxt) {
|
||||||
|
SFunctionNode* pFunc = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
|
CHECK_OUT_OF_MEM(pFunc);
|
||||||
|
strcpy(pFunc->functionName, "count");
|
||||||
|
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt))) {
|
||||||
|
nodesDestroyNode(pFunc);
|
||||||
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
|
}
|
||||||
|
return (SNode*)pFunc;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) {
|
SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT);
|
SDeleteStmt* pStmt = nodesMakeNode(QUERY_NODE_DELETE_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->pFromTable = pTable;
|
pStmt->pFromTable = pTable;
|
||||||
pStmt->pWhere = pWhere;
|
pStmt->pWhere = pWhere;
|
||||||
|
pStmt->pCountFunc = createCountFuncForDelete(pCxt);
|
||||||
|
if (NULL == pStmt->pCountFunc) {
|
||||||
|
nodesDestroyNode(pStmt);
|
||||||
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
|
}
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,11 +180,11 @@ static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromCreateTable(SCollectMetaKeyCxt* pCxt, SCreateTableStmt* pStmt) {
|
static int32_t collectMetaKeyFromCreateTable(SCollectMetaKeyCxt* pCxt, SCreateTableStmt* pStmt) {
|
||||||
if (NULL == pStmt->pTags) {
|
int32_t code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
||||||
return reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
if (TSDB_CODE_SUCCESS == code && NULL == pStmt->pTags) {
|
||||||
} else {
|
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache);
|
||||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache);
|
|
||||||
}
|
}
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCreateMultiTableStmt* pStmt) {
|
static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCreateMultiTableStmt* pStmt) {
|
||||||
|
|
@ -192,8 +192,11 @@ static int32_t collectMetaKeyFromCreateMultiTable(SCollectMetaKeyCxt* pCxt, SCre
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pStmt->pSubTables) {
|
FOREACH(pNode, pStmt->pSubTables) {
|
||||||
SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
|
SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
|
||||||
|
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pClause->dbName, pCxt->pMetaCache);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code =
|
code =
|
||||||
reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pClause->useTableName, pCxt->pMetaCache);
|
reserveTableMetaInCache(pCxt->pParseCxt->acctId, pClause->useDbName, pClause->useTableName, pCxt->pMetaCache);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, pCxt->pMetaCache);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con
|
||||||
|
|
||||||
static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass) {
|
static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass) {
|
||||||
SParseContext* pBasicCtx = pCxt->pComCxt;
|
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||||
if (NULL != pCxt->pMetaCache) {
|
if (pBasicCtx->async) {
|
||||||
return getUserAuthFromCache(pCxt->pMetaCache, pBasicCtx->pUser, pDbFname, AUTH_TYPE_WRITE, pPass);
|
return getUserAuthFromCache(pCxt->pMetaCache, pBasicCtx->pUser, pDbFname, AUTH_TYPE_WRITE, pPass);
|
||||||
}
|
}
|
||||||
return catalogChkAuth(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pBasicCtx->pUser, pDbFname,
|
return catalogChkAuth(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pBasicCtx->pUser, pDbFname,
|
||||||
|
|
@ -263,7 +263,7 @@ static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass)
|
||||||
|
|
||||||
static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool isStb, STableMeta** pTableMeta) {
|
static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool isStb, STableMeta** pTableMeta) {
|
||||||
SParseContext* pBasicCtx = pCxt->pComCxt;
|
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||||
if (NULL != pCxt->pMetaCache) {
|
if (pBasicCtx->async) {
|
||||||
return getTableMetaFromCache(pCxt->pMetaCache, pTbName, pTableMeta);
|
return getTableMetaFromCache(pCxt->pMetaCache, pTbName, pTableMeta);
|
||||||
}
|
}
|
||||||
if (isStb) {
|
if (isStb) {
|
||||||
|
|
@ -275,7 +275,7 @@ static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool is
|
||||||
|
|
||||||
static int32_t getTableVgroup(SInsertParseContext* pCxt, SName* pTbName, SVgroupInfo* pVg) {
|
static int32_t getTableVgroup(SInsertParseContext* pCxt, SName* pTbName, SVgroupInfo* pVg) {
|
||||||
SParseContext* pBasicCtx = pCxt->pComCxt;
|
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||||
if (NULL != pCxt->pMetaCache) {
|
if (pBasicCtx->async) {
|
||||||
return getTableVgroupFromCache(pCxt->pMetaCache, pTbName, pVg);
|
return getTableVgroupFromCache(pCxt->pMetaCache, pTbName, pVg);
|
||||||
}
|
}
|
||||||
return catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pTbName, pVg);
|
return catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pTbName, pVg);
|
||||||
|
|
@ -305,6 +305,16 @@ static int32_t getSTableMeta(SInsertParseContext* pCxt, SName* name, char* dbFna
|
||||||
return getTableMetaImpl(pCxt, name, dbFname, true);
|
return getTableMetaImpl(pCxt, name, dbFname, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t getDBCfg(SInsertParseContext* pCxt, const char* pDbFName, SDbCfgInfo* pInfo) {
|
||||||
|
SParseContext* pBasicCtx = pCxt->pComCxt;
|
||||||
|
if (pBasicCtx->async) {
|
||||||
|
CHECK_CODE(getDbCfgFromCache(pCxt->pMetaCache, pDbFName, pInfo));
|
||||||
|
} else {
|
||||||
|
CHECK_CODE(catalogGetDBCfg(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, pDbFName, pInfo));
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) {
|
static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) {
|
||||||
while (start < end) {
|
while (start < end) {
|
||||||
if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) {
|
if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) {
|
||||||
|
|
@ -1090,10 +1100,10 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb
|
||||||
|
|
||||||
SName sname;
|
SName sname;
|
||||||
createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg);
|
createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg);
|
||||||
char stbFName[TSDB_TABLE_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
tNameExtractFullName(&sname, stbFName);
|
tNameGetFullDbName(&sname, dbFName);
|
||||||
|
|
||||||
CHECK_CODE(getSTableMeta(pCxt, &sname, stbFName));
|
CHECK_CODE(getSTableMeta(pCxt, &sname, dbFName));
|
||||||
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) {
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed");
|
return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed");
|
||||||
}
|
}
|
||||||
|
|
@ -1282,6 +1292,14 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) {
|
||||||
destroyBlockArrayList(pCxt->pVgDataBlocks);
|
destroyBlockArrayList(pCxt->pVgDataBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkSchemalessDb(SInsertParseContext* pCxt, char* pDbName) {
|
||||||
|
SDbCfgInfo pInfo = {0};
|
||||||
|
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||||
|
snprintf(fullName, sizeof(fullName), "%d.%s", pCxt->pComCxt->acctId, pDbName);
|
||||||
|
CHECK_CODE(getDBCfg(pCxt, fullName, &pInfo));
|
||||||
|
return pInfo.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// tb_name
|
// tb_name
|
||||||
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
|
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
|
||||||
// [(field1_name, ...)]
|
// [(field1_name, ...)]
|
||||||
|
|
@ -1335,7 +1353,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
SName name;
|
SName name;
|
||||||
CHECK_CODE(createSName(&name, &tbnameToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
CHECK_CODE(createSName(&name, &tbnameToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
||||||
|
|
||||||
CHECK_CODE(isNotSchemalessDb(pCxt->pComCxt, name.dbname));
|
CHECK_CODE(checkSchemalessDb(pCxt, name.dbname));
|
||||||
|
|
||||||
tNameExtractFullName(&name, tbFName);
|
tNameExtractFullName(&name, tbFName);
|
||||||
CHECK_CODE(taosHashPut(pCxt->pTableNameHashObj, tbFName, strlen(tbFName), &name, sizeof(SName)));
|
CHECK_CODE(taosHashPut(pCxt->pTableNameHashObj, tbFName, strlen(tbFName), &name, sizeof(SName)));
|
||||||
|
|
@ -1413,23 +1431,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
return buildOutput(pCxt);
|
return buildOutput(pCxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t isNotSchemalessDb(SParseContext* pContext, char *dbName){
|
|
||||||
SName name;
|
|
||||||
tNameSetDbName(&name, pContext->acctId, dbName, strlen(dbName));
|
|
||||||
char dbFname[TSDB_DB_FNAME_LEN] = {0};
|
|
||||||
tNameGetFullDbName(&name, dbFname);
|
|
||||||
SDbCfgInfo pInfo = {0};
|
|
||||||
int32_t code = catalogGetDBCfg(pContext->pCatalog, pContext->pTransporter, &pContext->mgmtEpSet, dbFname, &pInfo);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
parserError("catalogGetDBCfg error, code:%s, dbFName:%s", tstrerror(code), dbFname);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
if (pInfo.schemaless){
|
|
||||||
parserError("can not insert into schemaless db:%s", dbFname);
|
|
||||||
return TSDB_CODE_SML_INVALID_DB_CONF;
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
// INSERT INTO
|
// INSERT INTO
|
||||||
// tb_name
|
// tb_name
|
||||||
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
|
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
|
||||||
|
|
@ -1472,6 +1473,8 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
|
||||||
if (NULL == *pQuery) {
|
if (NULL == *pQuery) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
context.pMetaCache = (*pQuery)->pMetaCache;
|
||||||
}
|
}
|
||||||
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
(*pQuery)->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||||
(*pQuery)->haveResultSet = false;
|
(*pQuery)->haveResultSet = false;
|
||||||
|
|
@ -1586,12 +1589,20 @@ static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) {
|
||||||
static int32_t collectTableMetaKey(SInsertParseSyntaxCxt* pCxt, SToken* pTbToken) {
|
static int32_t collectTableMetaKey(SInsertParseSyntaxCxt* pCxt, SToken* pTbToken) {
|
||||||
SName name;
|
SName name;
|
||||||
CHECK_CODE(createSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
CHECK_CODE(createSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
||||||
|
CHECK_CODE(reserveDbCfgInCache(pCxt->pComCxt->acctId, name.dbname, pCxt->pMetaCache));
|
||||||
CHECK_CODE(reserveUserAuthInCacheExt(pCxt->pComCxt->pUser, &name, AUTH_TYPE_WRITE, pCxt->pMetaCache));
|
CHECK_CODE(reserveUserAuthInCacheExt(pCxt->pComCxt->pUser, &name, AUTH_TYPE_WRITE, pCxt->pMetaCache));
|
||||||
CHECK_CODE(reserveTableMetaInCacheExt(&name, pCxt->pMetaCache));
|
CHECK_CODE(reserveTableMetaInCacheExt(&name, pCxt->pMetaCache));
|
||||||
CHECK_CODE(reserveTableVgroupInCacheExt(&name, pCxt->pMetaCache));
|
CHECK_CODE(reserveTableVgroupInCacheExt(&name, pCxt->pMetaCache));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t collectAutoCreateTableMetaKey(SInsertParseSyntaxCxt* pCxt, SToken* pTbToken) {
|
||||||
|
SName name;
|
||||||
|
CHECK_CODE(createSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
||||||
|
CHECK_CODE(reserveTableVgroupInCacheExt(&name, pCxt->pMetaCache));
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
|
static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
|
||||||
bool hasData = false;
|
bool hasData = false;
|
||||||
// for each table
|
// for each table
|
||||||
|
|
@ -1620,6 +1631,7 @@ static int32_t parseInsertBodySyntax(SInsertParseSyntaxCxt* pCxt) {
|
||||||
|
|
||||||
// USING clause
|
// USING clause
|
||||||
if (TK_USING == sToken.type) {
|
if (TK_USING == sToken.type) {
|
||||||
|
CHECK_CODE(collectAutoCreateTableMetaKey(pCxt, &tbnameToken));
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
CHECK_CODE(collectTableMetaKey(pCxt, &sToken));
|
CHECK_CODE(collectTableMetaKey(pCxt, &sToken));
|
||||||
CHECK_CODE(skipUsingClause(pCxt));
|
CHECK_CODE(skipUsingClause(pCxt));
|
||||||
|
|
|
||||||
|
|
@ -938,7 +938,7 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||||
if (hasInvalidFuncNesting(pFunc->pParameterList)) {
|
if (hasInvalidFuncNesting(pFunc->pParameterList)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING);
|
||||||
}
|
}
|
||||||
if (pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc) {
|
if (NULL != pCxt->pCurrSelectStmt && pCxt->pCurrSelectStmt->hasIndefiniteRowsFunc) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2124,6 +2124,7 @@ static int32_t translateDelete(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
||||||
code = translateDeleteWhere(pCxt, pDelete);
|
code = translateDeleteWhere(pCxt, pDelete);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
pCxt->currClause = SQL_CLAUSE_SELECT;
|
||||||
code = translateExpr(pCxt, &pDelete->pCountFunc);
|
code = translateExpr(pCxt, &pDelete->pCountFunc);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -2653,8 +2654,23 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkSchemalessDb(STranslateContext* pCxt, const char* pDbName) {
|
||||||
|
if (0 != pCxt->pParseCxt->schemalessType) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
SDbCfgInfo info = {0};
|
||||||
|
int32_t code = getDBCfg(pCxt, pDbName, &info);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = info.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
|
||||||
int32_t code = checTableFactorOption(pCxt, pStmt->pOptions->filesFactor);
|
int32_t code = checkSchemalessDb(pCxt, pStmt->dbName);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checTableFactorOption(pCxt, pStmt->pOptions->filesFactor);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
|
code = checkTableRollupOption(pCxt, pStmt->pOptions->pRollupFuncs);
|
||||||
}
|
}
|
||||||
|
|
@ -2667,11 +2683,6 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkTableSchema(pCxt, pStmt);
|
code = checkTableSchema(pCxt, pStmt);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
if (pCxt->pParseCxt->schemalessType == 0) {
|
|
||||||
code = isNotSchemalessDb(pCxt->pParseCxt, pStmt->dbName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4445,11 +4456,11 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery)
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, pStmt->pSubTables) {
|
FOREACH(pNode, pStmt->pSubTables) {
|
||||||
if (pCxt->pParseCxt->schemalessType == 0 &&
|
SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
|
||||||
(code = isNotSchemalessDb(pCxt->pParseCxt, ((SCreateSubTableClause*)pNode)->dbName)) != TSDB_CODE_SUCCESS) {
|
code = checkSchemalessDb(pCxt, pClause->dbName);
|
||||||
return code;
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = rewriteCreateSubTable(pCxt, pClause, pVgroupHashmap);
|
||||||
}
|
}
|
||||||
code = rewriteCreateSubTable(pCxt, (SCreateSubTableClause*)pNode, pVgroupHashmap);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
taosHashCleanup(pVgroupHashmap);
|
taosHashCleanup(pVgroupHashmap);
|
||||||
return code;
|
return code;
|
||||||
|
|
@ -4860,12 +4871,7 @@ static int32_t buildModifyVnodeArray(STranslateContext* pCxt, SAlterTableStmt* p
|
||||||
|
|
||||||
static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) {
|
||||||
SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot;
|
SAlterTableStmt* pStmt = (SAlterTableStmt*)pQuery->pRoot;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = checkSchemalessDb(pCxt, pStmt->dbName);
|
||||||
if (pCxt->pParseCxt->schemalessType == 0 &&
|
|
||||||
(code = isNotSchemalessDb(pCxt->pParseCxt, pStmt->dbName)) != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMeta* pTableMeta = NULL;
|
STableMeta* pTableMeta = NULL;
|
||||||
code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta);
|
code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
|
|
||||||
|
|
@ -681,6 +681,7 @@ int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, S
|
||||||
tNameExtractFullName(pName, fullName);
|
tNameExtractFullName(pName, fullName);
|
||||||
STableMeta** pRes = taosHashGet(pMetaCache->pTableMeta, fullName, strlen(fullName));
|
STableMeta** pRes = taosHashGet(pMetaCache->pTableMeta, fullName, strlen(fullName));
|
||||||
if (NULL == pRes || NULL == *pRes) {
|
if (NULL == pRes || NULL == *pRes) {
|
||||||
|
parserError("getTableMetaFromCache error: %s", fullName);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
*pMeta = tableMetaDup(*pRes);
|
*pMeta = tableMetaDup(*pRes);
|
||||||
|
|
@ -709,6 +710,7 @@ int32_t reserveDbVgInfoInCache(int32_t acctId, const char* pDb, SParseMetaCache*
|
||||||
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo) {
|
int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo) {
|
||||||
SArray** pRes = taosHashGet(pMetaCache->pDbVgroup, pDbFName, strlen(pDbFName));
|
SArray** pRes = taosHashGet(pMetaCache->pDbVgroup, pDbFName, strlen(pDbFName));
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
|
parserError("getDbVgInfoFromCache error: %s", pDbFName);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
// *pRes is null, which is a legal value, indicating that the user DB has not been created
|
// *pRes is null, which is a legal value, indicating that the user DB has not been created
|
||||||
|
|
@ -736,6 +738,7 @@ int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
||||||
tNameExtractFullName(pName, fullName);
|
tNameExtractFullName(pName, fullName);
|
||||||
SVgroupInfo** pRes = taosHashGet(pMetaCache->pTableVgroup, fullName, strlen(fullName));
|
SVgroupInfo** pRes = taosHashGet(pMetaCache->pTableVgroup, fullName, strlen(fullName));
|
||||||
if (NULL == pRes || NULL == *pRes) {
|
if (NULL == pRes || NULL == *pRes) {
|
||||||
|
parserError("getTableVgroupFromCache error: %s", fullName);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
memcpy(pVgroup, *pRes, sizeof(SVgroupInfo));
|
memcpy(pVgroup, *pRes, sizeof(SVgroupInfo));
|
||||||
|
|
@ -750,6 +753,7 @@ int32_t getDbVgVersionFromCache(SParseMetaCache* pMetaCache, const char* pDbFNam
|
||||||
int32_t* pTableNum) {
|
int32_t* pTableNum) {
|
||||||
SDbInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName));
|
SDbInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName));
|
||||||
if (NULL == pRes || NULL == *pRes) {
|
if (NULL == pRes || NULL == *pRes) {
|
||||||
|
parserError("getDbVgVersionFromCache error: %s", pDbFName);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
*pVersion = (*pRes)->vgVer;
|
*pVersion = (*pRes)->vgVer;
|
||||||
|
|
@ -765,6 +769,7 @@ int32_t reserveDbCfgInCache(int32_t acctId, const char* pDb, SParseMetaCache* pM
|
||||||
int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo) {
|
int32_t getDbCfgFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SDbCfgInfo* pInfo) {
|
||||||
SDbCfgInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName));
|
SDbCfgInfo** pRes = taosHashGet(pMetaCache->pDbCfg, pDbFName, strlen(pDbFName));
|
||||||
if (NULL == pRes || NULL == *pRes) {
|
if (NULL == pRes || NULL == *pRes) {
|
||||||
|
parserError("getDbCfgFromCache error: %s", pDbFName);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
memcpy(pInfo, *pRes, sizeof(SDbCfgInfo));
|
memcpy(pInfo, *pRes, sizeof(SDbCfgInfo));
|
||||||
|
|
@ -803,6 +808,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
|
||||||
int32_t len = userAuthToStringExt(pUser, pDbFName, type, key);
|
int32_t len = userAuthToStringExt(pUser, pDbFName, type, key);
|
||||||
bool* pRes = taosHashGet(pMetaCache->pUserAuth, key, len);
|
bool* pRes = taosHashGet(pMetaCache->pUserAuth, key, len);
|
||||||
if (NULL == pRes) {
|
if (NULL == pRes) {
|
||||||
|
parserError("getUserAuthFromCache error: %s, %s, %d", pUser, pDbFName, type);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
*pPass = *pRes;
|
*pPass = *pRes;
|
||||||
|
|
@ -822,6 +828,7 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache) {
|
||||||
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) {
|
int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo) {
|
||||||
SFuncInfo** pRes = taosHashGet(pMetaCache->pUdf, pFunc, strlen(pFunc));
|
SFuncInfo** pRes = taosHashGet(pMetaCache->pUdf, pFunc, strlen(pFunc));
|
||||||
if (NULL == pRes || NULL == *pRes) {
|
if (NULL == pRes || NULL == *pRes) {
|
||||||
|
parserError("getUdfInfoFromCache error: %s", pFunc);
|
||||||
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
return TSDB_CODE_PAR_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
memcpy(pInfo, *pRes, sizeof(SFuncInfo));
|
memcpy(pInfo, *pRes, sizeof(SFuncInfo));
|
||||||
|
|
|
||||||
|
|
@ -4079,7 +4079,7 @@ static YYACTIONTYPE yy_reduce(
|
||||||
{
|
{
|
||||||
SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172);
|
SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172);
|
||||||
SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172);
|
SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172);
|
||||||
yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172)));
|
yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172)));
|
||||||
}
|
}
|
||||||
yymsp[-2].minor.yy172 = yylhsminor.yy172;
|
yymsp[-2].minor.yy172 = yylhsminor.yy172;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ TEST_F(ParserInitialDTest, delete) {
|
||||||
run("DELETE FROM t1");
|
run("DELETE FROM t1");
|
||||||
|
|
||||||
run("DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d");
|
run("DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d");
|
||||||
|
|
||||||
|
run("DELETE FROM st1");
|
||||||
|
|
||||||
|
run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserInitialDTest, deleteSemanticCheck) {
|
TEST_F(ParserInitialDTest, deleteSemanticCheck) {
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ class InsertTest : public Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t runAsync() {
|
int32_t runAsync() {
|
||||||
|
cxt_.async = true;
|
||||||
code_ = parseInsertSyntax(&cxt_, &res_);
|
code_ = parseInsertSyntax(&cxt_, &res_);
|
||||||
if (code_ != TSDB_CODE_SUCCESS) {
|
if (code_ != TSDB_CODE_SUCCESS) {
|
||||||
cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
cout << "parseInsertSyntax code:" << toString(code_) << ", msg:" << errMagBuf_ << endl;
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,15 @@ static int32_t rewriteExprForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESq
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteExpr(SNodeList* pExprs, SNode** pTarget) {
|
||||||
|
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||||
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
||||||
|
nodesRewriteExpr(pTarget, doRewriteExpr, &cxt);
|
||||||
|
return cxt.errCode;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t rewriteExprs(SNodeList* pExprs, SNodeList* pTarget) {
|
static int32_t rewriteExprs(SNodeList* pExprs, SNodeList* pTarget) {
|
||||||
|
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
||||||
nodesRewriteExprs(pTarget, doRewriteExpr, &cxt);
|
nodesRewriteExprs(pTarget, doRewriteExpr, &cxt);
|
||||||
return cxt.errCode;
|
return cxt.errCode;
|
||||||
|
|
@ -141,7 +149,7 @@ static int32_t createSelectRootLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols,
|
static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols, SNodeList* pScanCols,
|
||||||
STableMeta* pMeta) {
|
int8_t tableType) {
|
||||||
if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) {
|
if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) {
|
||||||
return SCAN_TYPE_STREAM;
|
return SCAN_TYPE_STREAM;
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +159,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
||||||
return NULL == pScanPseudoCols ? SCAN_TYPE_TABLE : SCAN_TYPE_TAG;
|
return NULL == pScanPseudoCols ? SCAN_TYPE_TABLE : SCAN_TYPE_TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_SYSTEM_TABLE == pMeta->tableType) {
|
if (TSDB_SYSTEM_TABLE == tableType) {
|
||||||
return SCAN_TYPE_SYSTEM_TABLE;
|
return SCAN_TYPE_SYSTEM_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,16 +212,18 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable,
|
static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealTable, bool hasRepeatScanFuncs,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSWAP(pScan->pMeta, pRealTable->pMeta);
|
// TSWAP(pScan->pMeta, pRealTable->pMeta);
|
||||||
TSWAP(pScan->pVgroupList, pRealTable->pVgroupList);
|
TSWAP(pScan->pVgroupList, pRealTable->pVgroupList);
|
||||||
pScan->scanSeq[0] = pSelect->hasRepeatScanFuncs ? 2 : 1;
|
pScan->tableId = pRealTable->pMeta->uid;
|
||||||
|
pScan->tableType = pRealTable->pMeta->tableType;
|
||||||
|
pScan->scanSeq[0] = hasRepeatScanFuncs ? 2 : 1;
|
||||||
pScan->scanSeq[1] = 0;
|
pScan->scanSeq[1] = 0;
|
||||||
pScan->scanRange = TSWINDOW_INITIALIZER;
|
pScan->scanRange = TSWINDOW_INITIALIZER;
|
||||||
pScan->tableName.type = TSDB_TABLE_NAME_T;
|
pScan->tableName.type = TSDB_TABLE_NAME_T;
|
||||||
|
|
@ -224,9 +234,21 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
pScan->ratio = pRealTable->ratio;
|
pScan->ratio = pRealTable->ratio;
|
||||||
pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD;
|
pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
|
||||||
|
*pLogicNode = (SLogicNode*)pScan;
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable,
|
||||||
|
SLogicNode** pLogicNode) {
|
||||||
|
SScanLogicNode* pScan = NULL;
|
||||||
|
int32_t code = makeScanLogicNode(pCxt, pRealTable, pSelect->hasRepeatScanFuncs, (SLogicNode**)&pScan);
|
||||||
|
|
||||||
// set columns to scan
|
// set columns to scan
|
||||||
int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, COLLECT_COL_TYPE_COL,
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, COLLECT_COL_TYPE_COL,
|
||||||
&pScan->pScanCols);
|
&pScan->pScanCols);
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, COLLECT_COL_TYPE_TAG,
|
code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, COLLECT_COL_TYPE_TAG,
|
||||||
|
|
@ -242,10 +264,10 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
code = rewriteExprForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM);
|
code = rewriteExprForSelect(pScan->pScanPseudoCols, pSelect, SQL_CLAUSE_FROM);
|
||||||
}
|
}
|
||||||
|
|
||||||
pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->pMeta);
|
pScan->scanType = getScanType(pCxt, pScan->pScanPseudoCols, pScan->pScanCols, pScan->tableType);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = addPrimaryKeyCol(pScan->pMeta->uid, &pScan->pScanCols);
|
code = addPrimaryKeyCol(pScan->tableId, &pScan->pScanCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set output
|
// set output
|
||||||
|
|
@ -549,7 +571,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
|
||||||
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval);
|
pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval);
|
||||||
pWindow->slidingUnit =
|
pWindow->slidingUnit =
|
||||||
(NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->unit : pWindow->intervalUnit);
|
(NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->unit : pWindow->intervalUnit);
|
||||||
pWindow->stmInterAlgo = STREAM_INTERVAL_ALGO_SINGLE;
|
pWindow->intervalAlgo = pCxt->pPlanCxt->streamQuery ? INTERVAL_ALGO_STREAM_SINGLE : INTERVAL_ALGO_HASH;
|
||||||
|
|
||||||
pWindow->pTspk = nodesCloneNode(pInterval->pCol);
|
pWindow->pTspk = nodesCloneNode(pInterval->pCol);
|
||||||
if (NULL == pWindow->pTspk) {
|
if (NULL == pWindow->pTspk) {
|
||||||
|
|
@ -980,10 +1002,11 @@ static int32_t getMsgType(ENodeType sqlType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) {
|
static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) {
|
||||||
SVnodeModifLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIF);
|
SVnodeModifyLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY);
|
||||||
if (NULL == pModif) {
|
if (NULL == pModif) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
pModif->modifyType = MODIFY_TABLE_TYPE_INSERT;
|
||||||
TSWAP(pModif->pDataBlocks, pStmt->pDataBlocks);
|
TSWAP(pModif->pDataBlocks, pStmt->pDataBlocks);
|
||||||
pModif->msgType = getMsgType(pStmt->sqlNodeType);
|
pModif->msgType = getMsgType(pStmt->sqlNodeType);
|
||||||
*pLogicNode = (SLogicNode*)pModif;
|
*pLogicNode = (SLogicNode*)pModif;
|
||||||
|
|
@ -996,26 +1019,96 @@ static int32_t createDeleteRootLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||||
return TSDB_CODE_FAILED;
|
SScanLogicNode* pScan = NULL;
|
||||||
|
int32_t code = makeScanLogicNode(pCxt, (SRealTableNode*)pDelete->pFromTable, false, (SLogicNode**)&pScan);
|
||||||
|
|
||||||
|
// set columns to scan
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
pScan->scanType = SCAN_TYPE_TABLE;
|
||||||
|
pScan->pScanCols = nodesCloneList(((SFunctionNode*)pDelete->pCountFunc)->pParameterList);
|
||||||
|
if (NULL == pScan->pScanCols) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pDelete->pTagIndexCond) {
|
||||||
|
pScan->pTagCond = nodesCloneNode(pDelete->pTagIndexCond);
|
||||||
|
if (NULL == pScan->pTagCond) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set output
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = createColumnByRewriteExps(pScan->pScanCols, &pScan->node.pTargets);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pLogicNode = (SLogicNode*)pScan;
|
||||||
|
} else {
|
||||||
|
nodesDestroyNode(pScan);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||||
return TSDB_CODE_FAILED;
|
SAggLogicNode* pAgg = (SAggLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG);
|
||||||
|
if (NULL == pAgg) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDeleteModifyTableLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
int32_t code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, nodesCloneNode(pDelete->pCountFunc));
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = rewriteExpr(pAgg->pAggFuncs, &pDelete->pCountFunc);
|
||||||
|
}
|
||||||
|
// set the output
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = createColumnByRewriteExps(pAgg->pAggFuncs, &pAgg->node.pTargets);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
*pLogicNode = (SLogicNode*)pAgg;
|
||||||
|
} else {
|
||||||
|
nodesDestroyNode(pAgg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDeleteStmt* pDelete,
|
||||||
SLogicNode** pLogicNode) {
|
SLogicNode** pLogicNode) {
|
||||||
return TSDB_CODE_FAILED;
|
SVnodeModifyLogicNode* pModify = (SVnodeModifyLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY);
|
||||||
|
if (NULL == pModify) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRealTableNode* pRealTable = (SRealTableNode*)pDelete->pFromTable;
|
||||||
|
|
||||||
|
pModify->modifyType = MODIFY_TABLE_TYPE_DELETE;
|
||||||
|
pModify->tableId = pRealTable->pMeta->uid;
|
||||||
|
pModify->tableType = pRealTable->pMeta->tableType;
|
||||||
|
snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId,
|
||||||
|
pRealTable->table.dbName, pRealTable->table.tableName);
|
||||||
|
pModify->deleteTimeRange = pDelete->timeRange;
|
||||||
|
pModify->pModifyRows = nodesCloneNode(pDelete->pCountFunc);
|
||||||
|
if (NULL == pModify->pModifyRows) {
|
||||||
|
nodesDestroyNode(pModify);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pLogicNode = (SLogicNode*)pModify;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
static int32_t createDeleteLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pDelete, SLogicNode** pLogicNode) {
|
||||||
SLogicNode* pRoot = NULL;
|
SLogicNode* pRoot = NULL;
|
||||||
int32_t code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteScanLogicNode, &pRoot);
|
int32_t code = createDeleteScanLogicNode(pCxt, pDelete, &pRoot);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteAggLogicNode, &pRoot);
|
code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteAggLogicNode, &pRoot);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createDeleteRootLogicNode(pCxt, pDelete, createDeleteModifyTableLogicNode, &pRoot);
|
code = createDeleteRootLogicNode(pCxt, pDelete, createVnodeModifLogicNodeByDelete, &pRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// todo: release after function splitting
|
// todo: release after function splitting
|
||||||
if (TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->pMeta->tableType &&
|
if (TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->tableType &&
|
||||||
SCAN_TYPE_STREAM != ((SScanLogicNode*)pNode)->scanType) {
|
SCAN_TYPE_STREAM != ((SScanLogicNode*)pNode)->scanType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -328,7 +328,7 @@ static int32_t cpdApplyTagIndex(SScanLogicNode* pScan, SNode** pTagCond, SNode**
|
||||||
|
|
||||||
static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* pScan) {
|
static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* pScan) {
|
||||||
if (NULL == pScan->node.pConditions || OPTIMIZE_FLAG_TEST_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_CPD) ||
|
if (NULL == pScan->node.pConditions || OPTIMIZE_FLAG_TEST_MASK(pScan->node.optimizedFlag, OPTIMIZE_FLAG_CPD) ||
|
||||||
TSDB_SYSTEM_TABLE == pScan->pMeta->tableType) {
|
TSDB_SYSTEM_TABLE == pScan->tableType) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -662,7 +662,7 @@ static int32_t opkGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimize, SNodeL
|
||||||
|
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
case QUERY_NODE_LOGIC_PLAN_SCAN:
|
||||||
if (TSDB_SUPER_TABLE != ((SScanLogicNode*)pNode)->pMeta->tableType) {
|
if (TSDB_SUPER_TABLE != ((SScanLogicNode*)pNode)->tableType) {
|
||||||
return nodesListMakeAppend(pScanNodes, pNode);
|
return nodesListMakeAppend(pScanNodes, pNode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -342,18 +342,7 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t getPrecision(SNodeList* pChildren) {
|
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, ENodeType type) {
|
||||||
if (1 == LIST_LENGTH(pChildren)) {
|
|
||||||
return (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision;
|
|
||||||
} else if (2 == LIST_LENGTH(pChildren)) {
|
|
||||||
uint8_t lp = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision;
|
|
||||||
uint8_t rp = (((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc)->precision;
|
|
||||||
return (lp > rp ? rp : lp);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, uint8_t precision, SLogicNode* pLogicNode, ENodeType type) {
|
|
||||||
SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type);
|
SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type);
|
||||||
if (NULL == pPhysiNode) {
|
if (NULL == pPhysiNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -364,7 +353,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, uint8_t precision, SLo
|
||||||
nodesDestroyNode(pPhysiNode);
|
nodesDestroyNode(pPhysiNode);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pPhysiNode->pOutputDataBlockDesc->precision = precision;
|
pPhysiNode->pOutputDataBlockDesc->precision = pLogicNode->precision;
|
||||||
return pPhysiNode;
|
return pPhysiNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -435,8 +424,8 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pScanPhysiNode->uid = pScanLogicNode->pMeta->uid;
|
pScanPhysiNode->uid = pScanLogicNode->tableId;
|
||||||
pScanPhysiNode->tableType = pScanLogicNode->pMeta->tableType;
|
pScanPhysiNode->tableType = pScanLogicNode->tableType;
|
||||||
memcpy(&pScanPhysiNode->tableName, &pScanLogicNode->tableName, sizeof(SName));
|
memcpy(&pScanPhysiNode->tableName, &pScanLogicNode->tableName, sizeof(SName));
|
||||||
if (NULL != pScanLogicNode->pTagCond) {
|
if (NULL != pScanLogicNode->pTagCond) {
|
||||||
pSubplan->pTagCond = nodesCloneNode(pScanLogicNode->pTagCond);
|
pSubplan->pTagCond = nodesCloneNode(pScanLogicNode->pTagCond);
|
||||||
|
|
@ -462,8 +451,8 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd
|
||||||
|
|
||||||
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(
|
STagScanPhysiNode* pTagScan =
|
||||||
pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
(STagScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
|
||||||
if (NULL == pTagScan) {
|
if (NULL == pTagScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -476,8 +465,7 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubpla
|
||||||
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
STableScanPhysiNode* pTableScan =
|
STableScanPhysiNode* pTableScan =
|
||||||
(STableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode,
|
(STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
||||||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
|
||||||
if (NULL == pTableScan) {
|
if (NULL == pTableScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -515,9 +503,8 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
|
||||||
|
|
||||||
static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SSystemTableScanPhysiNode* pScan =
|
SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode,
|
||||||
(SSystemTableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision,
|
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
||||||
(SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
|
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -567,8 +554,8 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
|
||||||
|
|
||||||
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode,
|
SJoinPhysiNode* pJoin =
|
||||||
QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
(SJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
|
||||||
if (NULL == pJoin) {
|
if (NULL == pJoin) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -750,8 +737,7 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi
|
||||||
|
|
||||||
static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode,
|
static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pAggLogicNode,
|
SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG);
|
||||||
QUERY_NODE_PHYSICAL_PLAN_AGG);
|
|
||||||
if (NULL == pAgg) {
|
if (NULL == pAgg) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -807,7 +793,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SIndefRowsFuncLogicNode* pFuncLogicNode, SPhysiNode** pPhyNode) {
|
SIndefRowsFuncLogicNode* pFuncLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SIndefRowsFuncPhysiNode* pIdfRowsFunc = (SIndefRowsFuncPhysiNode*)makePhysiNode(
|
SIndefRowsFuncPhysiNode* pIdfRowsFunc = (SIndefRowsFuncPhysiNode*)makePhysiNode(
|
||||||
pCxt, getPrecision(pChildren), (SLogicNode*)pFuncLogicNode, QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC);
|
pCxt, (SLogicNode*)pFuncLogicNode, QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC);
|
||||||
if (NULL == pIdfRowsFunc) {
|
if (NULL == pIdfRowsFunc) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -843,8 +829,8 @@ static int32_t createIndefRowsFuncPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
|
|
||||||
static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) {
|
SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(
|
SProjectPhysiNode* pProject =
|
||||||
pCxt, getPrecision(pChildren), (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
|
(SProjectPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
|
||||||
if (NULL == pProject) {
|
if (NULL == pProject) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -875,8 +861,8 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
|
||||||
|
|
||||||
static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(
|
SExchangePhysiNode* pExchange =
|
||||||
pCxt, pExchangeLogicNode->node.precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
(SExchangePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
|
||||||
if (NULL == pExchange) {
|
if (NULL == pExchange) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -889,8 +875,8 @@ static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogic
|
||||||
|
|
||||||
static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SScanPhysiNode* pScan = (SScanPhysiNode*)makePhysiNode(
|
SScanPhysiNode* pScan =
|
||||||
pCxt, pExchangeLogicNode->node.precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
(SScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
|
||||||
if (NULL == pScan) {
|
if (NULL == pScan) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -970,22 +956,28 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ENodeType getIntervalOperatorType(bool streamQuery, EStreamIntervalAlgorithm stmAlgo) {
|
static ENodeType getIntervalOperatorType(EIntervalAlgorithm intervalAlgo) {
|
||||||
if (streamQuery) {
|
switch (intervalAlgo) {
|
||||||
return STREAM_INTERVAL_ALGO_FINAL == stmAlgo
|
case INTERVAL_ALGO_HASH:
|
||||||
? QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
|
return QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL;
|
||||||
: (STREAM_INTERVAL_ALGO_SEMI == stmAlgo ? QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
|
case INTERVAL_ALGO_SORT_MERGE:
|
||||||
: QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL);
|
return QUERY_NODE_PHYSICAL_PLAN_SORT_MERGE_INTERVAL;
|
||||||
} else {
|
case INTERVAL_ALGO_STREAM_FINAL:
|
||||||
return QUERY_NODE_PHYSICAL_PLAN_INTERVAL;
|
return QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL;
|
||||||
|
case INTERVAL_ALGO_STREAM_SEMI:
|
||||||
|
return QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL;
|
||||||
|
case INTERVAL_ALGO_STREAM_SINGLE:
|
||||||
|
return QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(
|
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(
|
||||||
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode,
|
pCxt, (SLogicNode*)pWindowLogicNode, getIntervalOperatorType(pWindowLogicNode->intervalAlgo));
|
||||||
getIntervalOperatorType(pCxt->pPlanCxt->streamQuery, pWindowLogicNode->stmInterAlgo));
|
|
||||||
if (NULL == pInterval) {
|
if (NULL == pInterval) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -1002,7 +994,7 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
|
||||||
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(
|
SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(
|
||||||
pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode,
|
pCxt, (SLogicNode*)pWindowLogicNode,
|
||||||
(pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
|
(pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION_WINDOW
|
||||||
: QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW));
|
: QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW));
|
||||||
if (NULL == pSession) {
|
if (NULL == pSession) {
|
||||||
|
|
@ -1017,7 +1009,7 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
|
||||||
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SStateWinodwPhysiNode* pState =
|
SStateWinodwPhysiNode* pState =
|
||||||
(SStateWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode,
|
(SStateWinodwPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode,
|
||||||
(pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
|
(pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
|
||||||
: QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW));
|
: QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW));
|
||||||
if (NULL == pState) {
|
if (NULL == pState) {
|
||||||
|
|
@ -1069,8 +1061,8 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr
|
||||||
|
|
||||||
static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode,
|
static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pSortLogicNode,
|
SSortPhysiNode* pSort =
|
||||||
QUERY_NODE_PHYSICAL_PLAN_SORT);
|
(SSortPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT);
|
||||||
if (NULL == pSort) {
|
if (NULL == pSort) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -1110,8 +1102,8 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
|
|
||||||
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||||
SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
|
SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(
|
SPartitionPhysiNode* pPart =
|
||||||
pCxt, getPrecision(pChildren), (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
(SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
||||||
if (NULL == pPart) {
|
if (NULL == pPart) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -1151,8 +1143,7 @@ static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChi
|
||||||
|
|
||||||
static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SFillLogicNode* pFillNode,
|
static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SFillLogicNode* pFillNode,
|
||||||
SPhysiNode** pPhyNode) {
|
SPhysiNode** pPhyNode) {
|
||||||
SFillPhysiNode* pFill = (SFillPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pFillNode,
|
SFillPhysiNode* pFill = (SFillPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pFillNode, QUERY_NODE_PHYSICAL_PLAN_FILL);
|
||||||
QUERY_NODE_PHYSICAL_PLAN_FILL);
|
|
||||||
if (NULL == pFill) {
|
if (NULL == pFill) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -1205,8 +1196,8 @@ static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) {
|
static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pMergeLogicNode, SPhysiNode** pPhyNode) {
|
||||||
SMergePhysiNode* pMerge = (SMergePhysiNode*)makePhysiNode(
|
SMergePhysiNode* pMerge =
|
||||||
pCxt, pMergeLogicNode->node.precision, (SLogicNode*)pMergeLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
(SMergePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pMergeLogicNode, QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
||||||
if (NULL == pMerge) {
|
if (NULL == pMerge) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
@ -1347,6 +1338,62 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl
|
||||||
return pSubplan;
|
return pSubplan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t buildInsertSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, SSubplan* pSubplan) {
|
||||||
|
pSubplan->msgType = pModify->msgType;
|
||||||
|
pSubplan->execNode.epSet = pModify->pVgDataBlocks->vg.epSet;
|
||||||
|
SQueryNodeLoad node = {.addr = pSubplan->execNode, .load = 0};
|
||||||
|
taosArrayPush(pCxt->pExecNodeList, &node);
|
||||||
|
return createDataInserter(pCxt, pModify->pVgDataBlocks, &pSubplan->pDataSink);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, const SPhysiNode* pRoot,
|
||||||
|
SDataSinkNode** pSink) {
|
||||||
|
SDataDeleterNode* pDeleter = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_DELETE);
|
||||||
|
if (NULL == pDeleter) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDeleter->tableId = pModify->tableId;
|
||||||
|
pDeleter->tableType = pModify->tableType;
|
||||||
|
strcpy(pDeleter->tableFName, pModify->tableFName);
|
||||||
|
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
||||||
|
|
||||||
|
pDeleter->sink.pInputDataBlockDesc = nodesCloneNode(pRoot->pOutputDataBlockDesc);
|
||||||
|
if (NULL == pDeleter->sink.pInputDataBlockDesc) {
|
||||||
|
nodesDestroyNode(pDeleter);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pSink = (SDataSinkNode*)pDeleter;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t buildDeleteSubplan(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pModify, SSubplan* pSubplan) {
|
||||||
|
int32_t code =
|
||||||
|
createPhysiNode(pCxt, (SLogicNode*)nodesListGetNode(pModify->node.pChildren, 0), pSubplan, &pSubplan->pNode);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = createDataDeleter(pCxt, pModify, pSubplan->pNode, &pSubplan->pDataSink);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t buildVnodeModifySubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pSubplan) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
SVnodeModifyLogicNode* pModify = (SVnodeModifyLogicNode*)pLogicSubplan->pNode;
|
||||||
|
switch (pModify->modifyType) {
|
||||||
|
case MODIFY_TABLE_TYPE_INSERT:
|
||||||
|
code = buildInsertSubplan(pCxt, pModify, pSubplan);
|
||||||
|
break;
|
||||||
|
case MODIFY_TABLE_TYPE_DELETE:
|
||||||
|
code = buildDeleteSubplan(pCxt, pModify, pSubplan);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** pPhysiSubplan) {
|
static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan** pPhysiSubplan) {
|
||||||
SSubplan* pSubplan = makeSubplan(pCxt, pLogicSubplan);
|
SSubplan* pSubplan = makeSubplan(pCxt, pLogicSubplan);
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
|
|
@ -1356,12 +1403,7 @@ static int32_t createPhysiSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogic
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) {
|
if (SUBPLAN_TYPE_MODIFY == pLogicSubplan->subplanType) {
|
||||||
SVnodeModifLogicNode* pModif = (SVnodeModifLogicNode*)pLogicSubplan->pNode;
|
code = buildVnodeModifySubplan(pCxt, pLogicSubplan, pSubplan);
|
||||||
pSubplan->msgType = pModif->msgType;
|
|
||||||
pSubplan->execNode.epSet = pModif->pVgDataBlocks->vg.epSet;
|
|
||||||
SQueryNodeLoad node = {.addr = pSubplan->execNode, .load = 0};
|
|
||||||
taosArrayPush(pCxt->pExecNodeList, &node);
|
|
||||||
code = createDataInserter(pCxt, pModif->pVgDataBlocks, &pSubplan->pDataSink);
|
|
||||||
} else {
|
} else {
|
||||||
pSubplan->msgType = TDMT_VND_QUERY;
|
pSubplan->msgType = TDMT_VND_QUERY;
|
||||||
code = createPhysiNode(pCxt, pLogicSubplan->pNode, pSubplan, &pSubplan->pNode);
|
code = createPhysiNode(pCxt, pLogicSubplan->pNode, pSubplan, &pSubplan->pNode);
|
||||||
|
|
|
||||||
|
|
@ -38,26 +38,6 @@ static SLogicSubplan* singleCloneSubLogicPlan(SScaleOutContext* pCxt, SLogicSubp
|
||||||
return pDst;
|
return pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
|
||||||
SVnodeModifLogicNode* pNode = (SVnodeModifLogicNode*)pSubplan->pNode;
|
|
||||||
size_t numOfVgroups = taosArrayGetSize(pNode->pDataBlocks);
|
|
||||||
for (int32_t i = 0; i < numOfVgroups; ++i) {
|
|
||||||
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
|
||||||
if (NULL == pNewSubplan) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
((SVnodeModifLogicNode*)pNewSubplan->pNode)->pVgDataBlocks = (SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i);
|
|
||||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, pNewSubplan)) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t scaleOutForMerge(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
|
||||||
return nodesListStrictAppend(pGroup, singleCloneSubLogicPlan(pCxt, pSubplan, level));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t doSetScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup, bool* pFound) {
|
static int32_t doSetScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup, bool* pFound) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||||
|
|
@ -84,8 +64,7 @@ static int32_t setScanVgroup(SLogicNode* pNode, const SVgroupInfo* pVgroup) {
|
||||||
return doSetScanVgroup(pNode, pVgroup, &found);
|
return doSetScanVgroup(pNode, pVgroup, &found);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
static int32_t scaleOutByVgroups(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
if (pSubplan->pVgroupList && !pCxt->pPlanCxt->streamQuery) {
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
for (int32_t i = 0; i < pSubplan->pVgroupList->numOfVgroups; ++i) {
|
for (int32_t i = 0; i < pSubplan->pVgroupList->numOfVgroups; ++i) {
|
||||||
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||||
|
|
@ -101,6 +80,36 @@ static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t scaleOutForModify(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
|
SVnodeModifyLogicNode* pNode = (SVnodeModifyLogicNode*)pSubplan->pNode;
|
||||||
|
if (MODIFY_TABLE_TYPE_DELETE == pNode->modifyType) {
|
||||||
|
return scaleOutByVgroups(pCxt, pSubplan, level, pGroup);
|
||||||
|
} else {
|
||||||
|
size_t numOfVgroups = taosArrayGetSize(pNode->pDataBlocks);
|
||||||
|
for (int32_t i = 0; i < numOfVgroups; ++i) {
|
||||||
|
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||||
|
if (NULL == pNewSubplan) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
((SVnodeModifyLogicNode*)pNewSubplan->pNode)->pVgDataBlocks =
|
||||||
|
(SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i);
|
||||||
|
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, pNewSubplan)) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t scaleOutForMerge(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
|
return nodesListStrictAppend(pGroup, singleCloneSubLogicPlan(pCxt, pSubplan, level));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t scaleOutForScan(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pGroup) {
|
||||||
|
if (pSubplan->pVgroupList && !pCxt->pPlanCxt->streamQuery) {
|
||||||
|
return scaleOutByVgroups(pCxt, pSubplan, level, pGroup);
|
||||||
} else {
|
} else {
|
||||||
return scaleOutForMerge(pCxt, pSubplan, level, pGroup);
|
return scaleOutForMerge(pCxt, pSubplan, level, pGroup);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ static bool stbSplHasGatherExecFunc(const SNodeList* pFuncs) {
|
||||||
|
|
||||||
static bool stbSplIsMultiTbScan(bool streamQuery, SScanLogicNode* pScan) {
|
static bool stbSplIsMultiTbScan(bool streamQuery, SScanLogicNode* pScan) {
|
||||||
return (NULL != pScan->pVgroupList && pScan->pVgroupList->numOfVgroups > 1) ||
|
return (NULL != pScan->pVgroupList && pScan->pVgroupList->numOfVgroups > 1) ||
|
||||||
(streamQuery && TSDB_SUPER_TABLE == pScan->pMeta->tableType);
|
(streamQuery && TSDB_SUPER_TABLE == pScan->tableType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
|
static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
|
||||||
|
|
@ -315,27 +315,6 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicNode* pParent, S
|
||||||
return nodesListMakeAppend(&pParent->pChildren, pMerge);
|
return nodesListMakeAppend(&pParent->pChildren, pMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t stbSplSplitWindowNodeForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
|
||||||
SLogicNode* pPartWindow = NULL;
|
|
||||||
int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
SNodeList* pMergeKeys = NULL;
|
|
||||||
code = nodesListMakeStrictAppend(&pMergeKeys, nodesCloneNode(((SWindowLogicNode*)pInfo->pSplitNode)->pTspk));
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = stbSplCreateMergeNode(pCxt, pInfo->pSplitNode, pMergeKeys, pPartWindow);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
nodesDestroyList(pMergeKeys);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
|
||||||
splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
|
||||||
}
|
|
||||||
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent, SLogicNode* pPartChild) {
|
static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent, SLogicNode* pPartChild) {
|
||||||
SExchangeLogicNode* pExchange = NULL;
|
SExchangeLogicNode* pExchange = NULL;
|
||||||
int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange);
|
int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange);
|
||||||
|
|
@ -345,12 +324,28 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t stbSplSplitWindowNodeForBatch(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||||
|
SLogicNode* pPartWindow = NULL;
|
||||||
|
int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
((SWindowLogicNode*)pPartWindow)->intervalAlgo = INTERVAL_ALGO_HASH;
|
||||||
|
((SWindowLogicNode*)pInfo->pSplitNode)->intervalAlgo = INTERVAL_ALGO_SORT_MERGE;
|
||||||
|
code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartWindow);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren,
|
||||||
|
splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||||
|
}
|
||||||
|
pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t stbSplSplitWindowNodeForStream(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
static int32_t stbSplSplitWindowNodeForStream(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
|
||||||
SLogicNode* pPartWindow = NULL;
|
SLogicNode* pPartWindow = NULL;
|
||||||
int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow);
|
int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
((SWindowLogicNode*)pPartWindow)->stmInterAlgo = STREAM_INTERVAL_ALGO_SEMI;
|
((SWindowLogicNode*)pPartWindow)->intervalAlgo = INTERVAL_ALGO_STREAM_SEMI;
|
||||||
((SWindowLogicNode*)pInfo->pSplitNode)->stmInterAlgo = STREAM_INTERVAL_ALGO_FINAL;
|
((SWindowLogicNode*)pInfo->pSplitNode)->intervalAlgo = INTERVAL_ALGO_STREAM_FINAL;
|
||||||
code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartWindow);
|
code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartWindow);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
@ -834,6 +829,16 @@ static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) {
|
||||||
|
|
||||||
static void setLogicNodeParent(SLogicNode* pNode) { doSetLogicNodeParent(pNode, NULL); }
|
static void setLogicNodeParent(SLogicNode* pNode) { doSetLogicNodeParent(pNode, NULL); }
|
||||||
|
|
||||||
|
static void setVgroupsInfo(SLogicNode* pNode, SLogicSubplan* pSubplan) {
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) {
|
||||||
|
TSWAP(((SScanLogicNode*)pNode)->pVgroupList, pSubplan->pVgroupList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* pChild;
|
||||||
|
FOREACH(pChild, pNode->pChildren) { setVgroupsInfo((SLogicNode*)pChild, pSubplan); }
|
||||||
|
}
|
||||||
|
|
||||||
int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan** pLogicSubplan) {
|
int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan** pLogicSubplan) {
|
||||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
|
|
@ -845,17 +850,21 @@ int32_t splitLogicPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SLogicSubplan
|
||||||
nodesDestroyNode(pSubplan);
|
nodesDestroyNode(pSubplan);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIF == nodeType(pLogicNode)) {
|
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_MODIFY;
|
|
||||||
TSWAP(((SVnodeModifLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifLogicNode*)pSubplan->pNode)->pDataBlocks);
|
|
||||||
} else {
|
|
||||||
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
|
||||||
}
|
|
||||||
pSubplan->id.queryId = pCxt->queryId;
|
pSubplan->id.queryId = pCxt->queryId;
|
||||||
pSubplan->id.groupId = 1;
|
pSubplan->id.groupId = 1;
|
||||||
setLogicNodeParent(pSubplan->pNode);
|
setLogicNodeParent(pSubplan->pNode);
|
||||||
|
|
||||||
int32_t code = applySplitRule(pCxt, pSubplan);
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY == nodeType(pLogicNode)) {
|
||||||
|
pSubplan->subplanType = SUBPLAN_TYPE_MODIFY;
|
||||||
|
TSWAP(((SVnodeModifyLogicNode*)pLogicNode)->pDataBlocks, ((SVnodeModifyLogicNode*)pSubplan->pNode)->pDataBlocks);
|
||||||
|
setVgroupsInfo(pSubplan->pNode, pSubplan);
|
||||||
|
} else {
|
||||||
|
pSubplan->subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
|
code = applySplitRule(pCxt, pSubplan);
|
||||||
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pLogicSubplan = pSubplan;
|
*pLogicSubplan = pSubplan;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -60,3 +60,15 @@ TEST_F(PlanOtherTest, show) {
|
||||||
|
|
||||||
run("SHOW DATABASES");
|
run("SHOW DATABASES");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanOtherTest, delete) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("DELETE FROM t1");
|
||||||
|
|
||||||
|
run("DELETE FROM t1 WHERE ts > now - 2d and ts < now - 1d");
|
||||||
|
|
||||||
|
run("DELETE FROM st1");
|
||||||
|
|
||||||
|
run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ extern "C" {
|
||||||
#define QW_DEFAULT_SCH_TASK_NUMBER 10000
|
#define QW_DEFAULT_SCH_TASK_NUMBER 10000
|
||||||
#define QW_DEFAULT_SHORT_RUN_TIMES 2
|
#define QW_DEFAULT_SHORT_RUN_TIMES 2
|
||||||
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
|
#define QW_DEFAULT_HEARTBEAT_MSEC 5000
|
||||||
|
#define QW_SCH_TIMEOUT_MSEC 180000
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
QW_PHASE_PRE_QUERY = 1,
|
QW_PHASE_PRE_QUERY = 1,
|
||||||
|
|
@ -137,7 +138,7 @@ typedef struct SQWTaskCtx {
|
||||||
} SQWTaskCtx;
|
} SQWTaskCtx;
|
||||||
|
|
||||||
typedef struct SQWSchStatus {
|
typedef struct SQWSchStatus {
|
||||||
int32_t lastAccessTs; // timestamp in second
|
int64_t hbBrokenTs; // timestamp in msecond
|
||||||
SRWLatch hbConnLock;
|
SRWLatch hbConnLock;
|
||||||
SRpcHandleInfo hbConnInfo;
|
SRpcHandleInfo hbConnInfo;
|
||||||
SQueryNodeEpId hbEpId;
|
SQueryNodeEpId hbEpId;
|
||||||
|
|
@ -354,6 +355,8 @@ int32_t qwOpenRef(void);
|
||||||
void qwSetHbParam(int64_t refId, SQWHbParam **pParam);
|
void qwSetHbParam(int64_t refId, SQWHbParam **pParam);
|
||||||
int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type);
|
int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type);
|
||||||
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type);
|
||||||
|
void qwClearExpiredSch(SArray* pExpiredSch);
|
||||||
|
int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch);
|
||||||
|
|
||||||
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
void qwDbgDumpMgmtInfo(SQWorker *mgmt);
|
||||||
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore);
|
||||||
|
|
|
||||||
|
|
@ -535,3 +535,9 @@ int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void qwClearExpiredSch(SArray* pExpiredSch) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue