refactor code
This commit is contained in:
parent
072733d3f7
commit
7ddfe085f1
|
@ -97,5 +97,5 @@ int8_t validColCompress(uint8_t type, uint8_t l2);
|
|||
int8_t validColEncode(uint8_t type, uint8_t l1);
|
||||
|
||||
uint32_t createDefaultColCmprByType(uint8_t type);
|
||||
bool validColCmprByType(uint8_t type, uint32_t cmpr);
|
||||
int32_t validColCmprByType(uint8_t type, uint32_t cmpr);
|
||||
#endif /*_TD_TCOL_H_*/
|
||||
|
|
|
@ -397,10 +397,17 @@ uint32_t createDefaultColCmprByType(uint8_t type) {
|
|||
SET_COMPRESS(encode, compress, lvl, ret);
|
||||
return ret;
|
||||
}
|
||||
bool validColCmprByType(uint8_t type, uint32_t cmpr) {
|
||||
int32_t validColCmprByType(uint8_t type, uint32_t cmpr) {
|
||||
DEFINE_VAR(cmpr);
|
||||
if (validColEncode(type, l1) && validColCompress(type, l2) && validColCompressLevel(type, lvl)) {
|
||||
return true;
|
||||
if (!validColEncode(type, l1)) {
|
||||
return TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
}
|
||||
return false;
|
||||
if (!validColCompress(type, l2)) {
|
||||
return TSDB_CODE_TSC_COMPRESS_PARAM_ERROR;
|
||||
}
|
||||
|
||||
if (!validColCompressLevel(type, lvl)) {
|
||||
return TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1006,7 +1006,8 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) {
|
|||
pHead->vgId = htonl(pVgroup->vgId);
|
||||
tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq);
|
||||
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info};
|
||||
SRpcMsg rpcMsg = {
|
||||
.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info};
|
||||
SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup);
|
||||
int32_t code = tmsgSendReq(&epSet, &rpcMsg);
|
||||
if (code != 0) {
|
||||
|
@ -1752,9 +1753,10 @@ static int32_t mndUpdateSuperTableColumnCompress(SMnode *pMnode, const SStbObj *
|
|||
if (mndAllocStbSchemas(pOld, pNew) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (!validColCmprByType(pTarget->type, p->bytes)) {
|
||||
terrno = TSDB_CODE_TSC_ENCODE_PARAM_ERROR;
|
||||
return -1;
|
||||
code = validColCmprByType(pTarget->type, p->bytes);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
int8_t updated = 0;
|
||||
|
@ -3902,7 +3904,8 @@ typedef struct SMndDropTbsWithTsmaCtx {
|
|||
SArray *pResTbNames; // SArray<char*>
|
||||
} SMndDropTbsWithTsmaCtx;
|
||||
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId);
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWithTsmaCtx *pCtx, SArray *pTbs,
|
||||
int32_t vgId);
|
||||
|
||||
static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx *p) {
|
||||
if (!p) return;
|
||||
|
@ -3969,8 +3972,8 @@ _end:
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, const SVDropTbBatchReq* pReq, int32_t *len) {
|
||||
static void *mndBuildVDropTbsReq(SMnode *pMnode, const SVgroupInfo *pVgInfo, const SVDropTbBatchReq *pReq,
|
||||
int32_t *len) {
|
||||
int32_t contLen = 0;
|
||||
int32_t ret = 0;
|
||||
SMsgHead *pHead = NULL;
|
||||
|
@ -3999,7 +4002,8 @@ static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, con
|
|||
return pHead;
|
||||
}
|
||||
|
||||
static int32_t mndSetDropTbsRedoActions(SMnode* pMnode, STrans* pTrans, const SVDropTbVgReqs* pVgReqs, void* pCont, int32_t contLen) {
|
||||
static int32_t mndSetDropTbsRedoActions(SMnode *pMnode, STrans *pTrans, const SVDropTbVgReqs *pVgReqs, void *pCont,
|
||||
int32_t contLen) {
|
||||
STransAction action = {0};
|
||||
action.epSet = pVgReqs->info.epSet;
|
||||
action.pCont = pCont;
|
||||
|
@ -4055,8 +4059,7 @@ static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq) {
|
|||
terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, pReq->pTbs, pReq->vgInfo.vgId);
|
||||
if (terrno) goto _OVER;
|
||||
}
|
||||
if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0)
|
||||
code = 0;
|
||||
if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0) code = 0;
|
||||
_OVER:
|
||||
tFreeSMDropTbsReq(&dropReq);
|
||||
if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx);
|
||||
|
@ -4121,7 +4124,8 @@ int32_t vgHashValCmp(const void* lp, const void* rp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId) {
|
||||
static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode *pMnode, SMndDropTbsWithTsmaCtx *pCtx, SArray *pTbs,
|
||||
int32_t vgId) {
|
||||
int32_t code = 0;
|
||||
|
||||
SVgObj *pVgObj = mndAcquireVgroup(pMnode, vgId);
|
||||
|
@ -4129,7 +4133,10 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWith
|
|||
code = 0;
|
||||
goto _end;
|
||||
}
|
||||
SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin, .hashEnd = pVgObj->hashEnd, .numOfTable = pVgObj->numOfTables, .vgId = pVgObj->vgId};
|
||||
SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin,
|
||||
.hashEnd = pVgObj->hashEnd,
|
||||
.numOfTable = pVgObj->numOfTables,
|
||||
.vgId = pVgObj->vgId};
|
||||
vgInfo.epSet = mndGetVgroupEpset(pMnode, pVgObj);
|
||||
mndReleaseVgroup(pMnode, pVgObj);
|
||||
|
||||
|
@ -4137,7 +4144,6 @@ static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWith
|
|||
for (int32_t i = 0; i < pTbs->size; ++i) {
|
||||
const SVDropTbReq *pTb = taosArrayGet(pTbs, i);
|
||||
if (taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid))) {
|
||||
|
||||
} else {
|
||||
SMDropTbTsmaInfos infos = {0};
|
||||
infos.pTsmaInfos = taosArrayInit(2, sizeof(SMDropTbTsmaInfo));
|
||||
|
@ -4225,8 +4231,7 @@ static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pRsp) {
|
|||
|
||||
terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, rsp.pExpiredTbs, rsp.vgId);
|
||||
if (terrno) goto _end;
|
||||
if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0)
|
||||
code = 0;
|
||||
if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0) code = 0;
|
||||
_end:
|
||||
if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx);
|
||||
tDecoderClear(&decoder);
|
||||
|
|
Loading…
Reference in New Issue