Merge pull request #18516 from taosdata/feature/3_liaohj
refactor: do some internal refactor.
This commit is contained in:
commit
b56b9414a3
|
@ -27,7 +27,8 @@ extern "C" {
|
||||||
typedef int32_t (*__compar_fn_t)(const void *, const void *);
|
typedef int32_t (*__compar_fn_t)(const void *, const void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void *(*FCopy)(void *);
|
typedef void *(*__array_item_dup_fn_t)(void *);
|
||||||
|
|
||||||
typedef void (*FDelete)(void *);
|
typedef void (*FDelete)(void *);
|
||||||
typedef int32_t (*FEncode)(void **buf, const void *dst);
|
typedef int32_t (*FEncode)(void **buf, const void *dst);
|
||||||
typedef void *(*FDecode)(const void *buf, void *dst);
|
typedef void *(*FDecode)(const void *buf, void *dst);
|
||||||
|
@ -41,7 +42,6 @@ typedef void *(*FDecode)(const void *buf, void *dst);
|
||||||
#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx))
|
#define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx))
|
||||||
|
|
||||||
typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void *param);
|
typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void *param);
|
||||||
typedef void (*__ext_swap_fn_t)(void *p1, void *p2, const void *param);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* quick sort, with the compare function requiring additional parameters support
|
* quick sort, with the compare function requiring additional parameters support
|
||||||
|
|
|
@ -205,13 +205,7 @@ SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize);
|
||||||
* clone a new array
|
* clone a new array
|
||||||
* @param pSrc
|
* @param pSrc
|
||||||
*/
|
*/
|
||||||
SArray* taosArrayDup(const SArray* pSrc);
|
SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn);
|
||||||
|
|
||||||
/**
|
|
||||||
* deep copy a new array
|
|
||||||
* @param pSrc
|
|
||||||
*/
|
|
||||||
SArray* taosArrayDeepCopy(const SArray* pSrc, FCopy deepCopy);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear the array (remove all element)
|
* clear the array (remove all element)
|
||||||
|
|
|
@ -373,7 +373,7 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pNodeList) {
|
if (pNodeList) {
|
||||||
pInfo->pQnodeList = taosArrayDup(pNodeList);
|
pInfo->pQnodeList = taosArrayDup(pNodeList, NULL);
|
||||||
taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad);
|
taosArraySort(pInfo->pQnodeList, compareQueryNodeLoad);
|
||||||
tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%ld", pInfo->clusterId,
|
tscDebug("QnodeList updated in cluster 0x%" PRIx64 ", num:%ld", pInfo->clusterId,
|
||||||
taosArrayGetSize(pInfo->pQnodeList));
|
taosArrayGetSize(pInfo->pQnodeList));
|
||||||
|
@ -404,7 +404,7 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) {
|
||||||
|
|
||||||
taosThreadMutexLock(&pInfo->qnodeMutex);
|
taosThreadMutexLock(&pInfo->qnodeMutex);
|
||||||
if (pInfo->pQnodeList) {
|
if (pInfo->pQnodeList) {
|
||||||
*pNodeList = taosArrayDup(pInfo->pQnodeList);
|
*pNodeList = taosArrayDup(pInfo->pQnodeList, NULL);
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&pInfo->qnodeMutex);
|
taosThreadMutexUnlock(&pInfo->qnodeMutex);
|
||||||
|
|
||||||
|
@ -593,13 +593,13 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray
|
||||||
if (pRes->code) {
|
if (pRes->code) {
|
||||||
pQnodeList = NULL;
|
pQnodeList = NULL;
|
||||||
} else {
|
} else {
|
||||||
pQnodeList = taosArrayDup((SArray*)pRes->pRes);
|
pQnodeList = taosArrayDup((SArray*)pRes->pRes, NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo;
|
SAppInstInfo* pInst = pRequest->pTscObj->pAppInfo;
|
||||||
taosThreadMutexLock(&pInst->qnodeMutex);
|
taosThreadMutexLock(&pInst->qnodeMutex);
|
||||||
if (pInst->pQnodeList) {
|
if (pInst->pQnodeList) {
|
||||||
pQnodeList = taosArrayDup(pInst->pQnodeList);
|
pQnodeList = taosArrayDup(pInst->pQnodeList, NULL);
|
||||||
}
|
}
|
||||||
taosThreadMutexUnlock(&pInst->qnodeMutex);
|
taosThreadMutexUnlock(&pInst->qnodeMutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
|
||||||
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
static void dmResetEps(SDnodeData *pData, SArray *dnodeEps) {
|
||||||
if (pData->dnodeEps != dnodeEps) {
|
if (pData->dnodeEps != dnodeEps) {
|
||||||
SArray *tmp = pData->dnodeEps;
|
SArray *tmp = pData->dnodeEps;
|
||||||
pData->dnodeEps = taosArrayDup(dnodeEps);
|
pData->dnodeEps = taosArrayDup(dnodeEps, NULL);
|
||||||
taosArrayDestroy(tmp);
|
taosArrayDestroy(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -810,7 +810,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
|
||||||
|
|
||||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||||
if (dbObj.cfg.pRetensions != NULL) {
|
if (dbObj.cfg.pRetensions != NULL) {
|
||||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions);
|
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
|
||||||
if (dbObj.cfg.pRetensions == NULL) goto _OVER;
|
if (dbObj.cfg.pRetensions == NULL) goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,7 @@ SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) {
|
||||||
SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp));
|
SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp));
|
||||||
if (pConsumerEpNew == NULL) return NULL;
|
if (pConsumerEpNew == NULL) return NULL;
|
||||||
pConsumerEpNew->consumerId = pConsumerEpOld->consumerId;
|
pConsumerEpNew->consumerId = pConsumerEpOld->consumerId;
|
||||||
pConsumerEpNew->vgs = taosArrayDeepCopy(pConsumerEpOld->vgs, (FCopy)tCloneSMqVgEp);
|
pConsumerEpNew->vgs = taosArrayDup(pConsumerEpOld->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
|
||||||
return pConsumerEpNew;
|
return pConsumerEpNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,11 +440,11 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
|
||||||
pConsumerEp = (SMqConsumerEp *)pIter;
|
pConsumerEp = (SMqConsumerEp *)pIter;
|
||||||
SMqConsumerEp newEp = {
|
SMqConsumerEp newEp = {
|
||||||
.consumerId = pConsumerEp->consumerId,
|
.consumerId = pConsumerEp->consumerId,
|
||||||
.vgs = taosArrayDeepCopy(pConsumerEp->vgs, (FCopy)tCloneSMqVgEp),
|
.vgs = taosArrayDup(pConsumerEp->vgs, (__array_item_dup_fn_t)tCloneSMqVgEp),
|
||||||
};
|
};
|
||||||
taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp, sizeof(SMqConsumerEp));
|
taosHashPut(pSubNew->consumerHash, &newEp.consumerId, sizeof(int64_t), &newEp, sizeof(SMqConsumerEp));
|
||||||
}
|
}
|
||||||
pSubNew->unassignedVgs = taosArrayDeepCopy(pSub->unassignedVgs, (FCopy)tCloneSMqVgEp);
|
pSubNew->unassignedVgs = taosArrayDup(pSub->unassignedVgs, (__array_item_dup_fn_t)tCloneSMqVgEp);
|
||||||
memcpy(pSubNew->dbName, pSub->dbName, TSDB_DB_FNAME_LEN);
|
memcpy(pSubNew->dbName, pSub->dbName, TSDB_DB_FNAME_LEN);
|
||||||
return pSubNew;
|
return pSubNew;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
|
||||||
SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
|
SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
|
||||||
if (pEntryNew == NULL) return NULL;
|
if (pEntryNew == NULL) return NULL;
|
||||||
pEntryNew->epoch = pEntry->epoch;
|
pEntryNew->epoch = pEntry->epoch;
|
||||||
pEntryNew->consumers = taosArrayDeepCopy(pEntry->consumers, (FCopy)tCloneSMqConsumerEp);
|
pEntryNew->consumers = taosArrayDup(pEntry->consumers, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||||
return pEntryNew;
|
return pEntryNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ SMqSubActionLogObj *tCloneSMqSubActionLogObj(SMqSubActionLogObj *pLog) {
|
||||||
SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
|
SMqSubActionLogObj *pLogNew = taosMemoryMalloc(sizeof(SMqSubActionLogObj));
|
||||||
if (pLogNew == NULL) return pLogNew;
|
if (pLogNew == NULL) return pLogNew;
|
||||||
memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
|
memcpy(pLogNew->key, pLog->key, TSDB_SUBSCRIBE_KEY_LEN);
|
||||||
pLogNew->logs = taosArrayDeepCopy(pLog->logs, (FCopy)tCloneSMqConsumerEp);
|
pLogNew->logs = taosArrayDup(pLog->logs, (__array_item_dup_fn_t)tCloneSMqConsumerEp);
|
||||||
return pLogNew;
|
return pLogNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1684,7 +1684,7 @@ static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStb->numOfFuncs > 0) {
|
if (pStb->numOfFuncs > 0) {
|
||||||
pRsp->pFuncs = taosArrayDup(pStb->pFuncs);
|
pRsp->pFuncs = taosArrayDup(pStb->pFuncs, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosRUnLockLatch(&pStb->lock);
|
taosRUnLockLatch(&pStb->lock);
|
||||||
|
|
|
@ -1188,7 +1188,7 @@ SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch) {
|
||||||
return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx);
|
return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||||
|
|
||||||
static void ctgFreeDbVgroup(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
static void ctgFreeDbVgroup(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ static void* ctgCloneVgroupInfo(void* pSrc) {
|
||||||
|
|
||||||
static void ctgFreeVgroupInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
static void ctgFreeVgroupInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||||
|
|
||||||
static void ctgFreeTableIndices(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
static void ctgFreeTableIndices(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
|
@ -1275,7 +1275,7 @@ static void* ctgCloneUserAuth(void* pSrc) {
|
||||||
|
|
||||||
static void ctgFreeUserAuth(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
static void ctgFreeUserAuth(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||||
|
|
||||||
static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
|
@ -1290,11 +1290,11 @@ static void* ctgCloneTableCfg(void* pSrc) {
|
||||||
|
|
||||||
static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); }
|
static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc, NULL); }
|
||||||
|
|
||||||
static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
static int32_t ctgCloneMetaDataArray(SArray* pSrc, FCopy copyFunc, SArray** pDst) {
|
static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) {
|
||||||
if (NULL == pSrc) {
|
if (NULL == pSrc) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2355,10 +2355,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < tableListGetSize(pTableListInfo); ++i) {
|
size_t num = taosArrayGetSize(pList);
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
STableKeyInfo* p = taosArrayGet(pList, i);
|
STableKeyInfo* p = taosArrayGet(pList, i);
|
||||||
tableListAddTableInfo(pTableListInfo, p->uid, 0);
|
tableListAddTableInfo(pTableListInfo, p->uid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pList);
|
taosArrayDestroy(pList);
|
||||||
} else { // Create group with only one table
|
} else { // Create group with only one table
|
||||||
tableListAddTableInfo(pTableListInfo, pBlockNode->uid, 0);
|
tableListAddTableInfo(pTableListInfo, pBlockNode->uid, 0);
|
||||||
|
|
|
@ -36,7 +36,7 @@ void monRecordLog(int64_t ts, ELogLevel level, const char *content) {
|
||||||
|
|
||||||
int32_t monGetLogs(SMonLogs *logs) {
|
int32_t monGetLogs(SMonLogs *logs) {
|
||||||
taosThreadMutexLock(&tsMonitor.lock);
|
taosThreadMutexLock(&tsMonitor.lock);
|
||||||
logs->logs = taosArrayDup(tsMonitor.logs);
|
logs->logs = taosArrayDup(tsMonitor.logs, NULL);
|
||||||
logs->numOfInfoLogs = tsNumOfInfoLogs;
|
logs->numOfInfoLogs = tsNumOfInfoLogs;
|
||||||
logs->numOfErrorLogs = tsNumOfErrorLogs;
|
logs->numOfErrorLogs = tsNumOfErrorLogs;
|
||||||
logs->numOfDebugLogs = tsNumOfDebugLogs;
|
logs->numOfDebugLogs = tsNumOfDebugLogs;
|
||||||
|
|
|
@ -169,7 +169,7 @@ static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bo
|
||||||
static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
|
static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
|
||||||
SArray* pAssociation = NULL;
|
SArray* pAssociation = NULL;
|
||||||
if (NULL != ((SExprNode*)pProject)->pAssociation) {
|
if (NULL != ((SExprNode*)pProject)->pAssociation) {
|
||||||
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation);
|
pAssociation = taosArrayDup(((SExprNode*)pProject)->pAssociation, NULL);
|
||||||
if (NULL == pAssociation) {
|
if (NULL == pAssociation) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,7 +857,7 @@ void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, i
|
||||||
pTbReq->ctb.tagNum = tagNum;
|
pTbReq->ctb.tagNum = tagNum;
|
||||||
if (sname) pTbReq->ctb.stbName = strdup(sname);
|
if (sname) pTbReq->ctb.stbName = strdup(sname);
|
||||||
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
pTbReq->ctb.pTag = (uint8_t*)pTag;
|
||||||
pTbReq->ctb.tagName = taosArrayDup(tagName);
|
pTbReq->ctb.tagName = taosArrayDup(tagName, NULL);
|
||||||
pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL;
|
pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL;
|
||||||
pTbReq->commentLen = -1;
|
pTbReq->commentLen = -1;
|
||||||
|
|
||||||
|
|
|
@ -6625,7 +6625,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
|
||||||
req.ctb.tagNum = tagNum;
|
req.ctb.tagNum = tagNum;
|
||||||
req.ctb.stbName = strdup(sTableNmae);
|
req.ctb.stbName = strdup(sTableNmae);
|
||||||
req.ctb.pTag = (uint8_t*)pTag;
|
req.ctb.pTag = (uint8_t*)pTag;
|
||||||
req.ctb.tagName = taosArrayDup(tagName);
|
req.ctb.tagName = taosArrayDup(tagName, NULL);
|
||||||
if (pStmt->ignoreExists) {
|
if (pStmt->ignoreExists) {
|
||||||
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
req.flags |= TD_CREATE_IF_NOT_EXISTS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,7 +844,7 @@ int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName,
|
||||||
int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbVgroup, (void**)&pVgList);
|
int32_t code = getMetaDataFromHash(pDbFName, strlen(pDbFName), pMetaCache->pDbVgroup, (void**)&pVgList);
|
||||||
// pVgList is null, which is a legal value, indicating that the user DB has not been created
|
// pVgList is null, which is a legal value, indicating that the user DB has not been created
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pVgList) {
|
||||||
*pVgInfo = taosArrayDup(pVgList);
|
*pVgInfo = taosArrayDup(pVgList, NULL);
|
||||||
if (NULL == *pVgInfo) {
|
if (NULL == *pVgInfo) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -961,7 +961,7 @@ int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFun
|
||||||
static void destroySmaIndex(void* p) { taosMemoryFree(((STableIndexInfo*)p)->expr); }
|
static void destroySmaIndex(void* p) { taosMemoryFree(((STableIndexInfo*)p)->expr); }
|
||||||
|
|
||||||
static SArray* smaIndexesDup(SArray* pSrc) {
|
static SArray* smaIndexesDup(SArray* pSrc) {
|
||||||
SArray* pDst = taosArrayDup(pSrc);
|
SArray* pDst = taosArrayDup(pSrc, NULL);
|
||||||
if (NULL == pDst) {
|
if (NULL == pDst) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1011,7 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
|
||||||
memcpy(pNew->pComment, pCfg->pComment, pNew->commentLen);
|
memcpy(pNew->pComment, pCfg->pComment, pNew->commentLen);
|
||||||
}
|
}
|
||||||
if (NULL != pNew->pFuncs) {
|
if (NULL != pNew->pFuncs) {
|
||||||
pNew->pFuncs = taosArrayDup(pNew->pFuncs);
|
pNew->pFuncs = taosArrayDup(pNew->pFuncs, NULL);
|
||||||
}
|
}
|
||||||
if (NULL != pNew->pTags) {
|
if (NULL != pNew->pTags) {
|
||||||
pNew->pTags = taosMemoryCalloc(pNew->tagsLen + 1, 1);
|
pNew->pTags = taosMemoryCalloc(pNew->tagsLen + 1, 1);
|
||||||
|
@ -1053,7 +1053,7 @@ int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes) {
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pDnodes = taosArrayDup((SArray*)pRes->pRes);
|
*pDnodes = taosArrayDup((SArray*)pRes->pRes, NULL);
|
||||||
if (NULL == *pDnodes) {
|
if (NULL == *pDnodes) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1543,51 +1543,73 @@ void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
|
||||||
int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex,
|
int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex,
|
||||||
int32_t numOfRows, int32_t step, __compar_fn_t fp, int32_t optr) {
|
int32_t numOfRows, int32_t step, __compar_fn_t fp, int32_t optr) {
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
|
bool * pRes = (bool *)pOut->columnData->pData;
|
||||||
|
|
||||||
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_JSON || GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_JSON) {
|
||||||
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
for (int32_t i = startIndex; i < numOfRows && i >= startIndex; i += step) {
|
||||||
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
||||||
|
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
||||||
|
|
||||||
if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) {
|
if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
char * pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||||
char *pRightData = colDataGetData(pRight->columnData, rightIndex);
|
char * pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||||
int64_t leftOut = 0;
|
int64_t leftOut = 0;
|
||||||
int64_t rightOut = 0;
|
int64_t rightOut = 0;
|
||||||
bool freeLeft = false;
|
bool freeLeft = false;
|
||||||
bool freeRight = false;
|
bool freeRight = false;
|
||||||
bool isJsonnull = false;
|
bool isJsonnull = false;
|
||||||
|
|
||||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData,
|
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData,
|
||||||
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);
|
&leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight);
|
||||||
if (isJsonnull) {
|
if (isJsonnull) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pLeftData || !pRightData) {
|
if (!pLeftData || !pRightData) {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&result);
|
colDataAppendInt8(pOut->columnData, i, (int8_t *)&result);
|
||||||
} else {
|
} else {
|
||||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||||
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
colDataAppendInt8(pOut->columnData, i, (int8_t *)&res);
|
||||||
if (res) {
|
if (res) {
|
||||||
++num;
|
++num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freeLeft) {
|
||||||
|
taosMemoryFreeClear(pLeftData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freeRight) {
|
||||||
|
taosMemoryFreeClear(pRightData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
||||||
|
int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i;
|
||||||
|
int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i;
|
||||||
|
|
||||||
if (freeLeft) {
|
if (colDataIsNull_s(pLeft->columnData, leftIndex) ||
|
||||||
taosMemoryFreeClear(pLeftData);
|
colDataIsNull_s(pRight->columnData, rightIndex)) {
|
||||||
}
|
pRes[i] = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (freeRight) {
|
char *pLeftData = colDataGetData(pLeft->columnData, leftIndex);
|
||||||
taosMemoryFreeClear(pRightData);
|
char *pRightData = colDataGetData(pRight->columnData, rightIndex);
|
||||||
|
|
||||||
|
pRes[i] = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||||
|
if (pRes[i]) {
|
||||||
|
++num;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -721,7 +721,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
|
||||||
if (pReq->pNodeList == NULL || taosArrayGetSize(pReq->pNodeList) <= 0) {
|
if (pReq->pNodeList == NULL || taosArrayGetSize(pReq->pNodeList) <= 0) {
|
||||||
qDebug("QID:0x%" PRIx64 " input exec nodeList is empty", pReq->pDag->queryId);
|
qDebug("QID:0x%" PRIx64 " input exec nodeList is empty", pReq->pDag->queryId);
|
||||||
} else {
|
} else {
|
||||||
pJob->nodeList = taosArrayDup(pReq->pNodeList);
|
pJob->nodeList = taosArrayDup(pReq->pNodeList, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pJob->taskList = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false,
|
pJob->taskList = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false,
|
||||||
|
|
|
@ -302,7 +302,7 @@ SArray* taosArrayFromList(const void* src, size_t size, size_t elemSize) {
|
||||||
return pDst;
|
return pDst;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* taosArrayDup(const SArray* pSrc) {
|
SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn) {
|
||||||
assert(pSrc != NULL);
|
assert(pSrc != NULL);
|
||||||
|
|
||||||
if (pSrc->size == 0) { // empty array list
|
if (pSrc->size == 0) { // empty array list
|
||||||
|
@ -311,8 +311,19 @@ SArray* taosArrayDup(const SArray* pSrc) {
|
||||||
|
|
||||||
SArray* dst = taosArrayInit(pSrc->size, pSrc->elemSize);
|
SArray* dst = taosArrayInit(pSrc->size, pSrc->elemSize);
|
||||||
|
|
||||||
memcpy(dst->pData, pSrc->pData, pSrc->elemSize * pSrc->size);
|
if (fn == NULL) {
|
||||||
|
memcpy(dst->pData, pSrc->pData, pSrc->elemSize * pSrc->size);
|
||||||
|
} else {
|
||||||
|
ASSERT(pSrc->elemSize == sizeof(void*));
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < pSrc->size; ++i) {
|
||||||
|
void* p = fn(taosArrayGetP(pSrc, i));
|
||||||
|
memcpy(((char*)dst->pData )+ i * dst->elemSize, &p, dst->elemSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dst->size = pSrc->size;
|
dst->size = pSrc->size;
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,19 +475,6 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* taosArrayDeepCopy(const SArray* pSrc, FCopy deepCopy) {
|
|
||||||
if (NULL == pSrc) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ASSERT(pSrc->elemSize == sizeof(void*));
|
|
||||||
SArray* pArray = taosArrayInit(pSrc->size, sizeof(void*));
|
|
||||||
for (int32_t i = 0; i < pSrc->size; i++) {
|
|
||||||
void* clone = deepCopy(taosArrayGetP(pSrc, i));
|
|
||||||
taosArrayPush(pArray, &clone);
|
|
||||||
}
|
|
||||||
return pArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode) {
|
int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
int32_t sz = pArray->size;
|
int32_t sz = pArray->size;
|
||||||
|
|
Loading…
Reference in New Issue