feat: add compare parameter that enable/disable group id comparision
This commit is contained in:
parent
aa46624bc5
commit
fadc11b685
|
@ -50,6 +50,7 @@ typedef struct SMsortComparParam {
|
||||||
void **pSources;
|
void **pSources;
|
||||||
int32_t numOfSources;
|
int32_t numOfSources;
|
||||||
SArray *orderInfo; // SArray<SBlockOrderInfo>
|
SArray *orderInfo; // SArray<SBlockOrderInfo>
|
||||||
|
bool cmpGroupId;
|
||||||
} SMsortComparParam;
|
} SMsortComparParam;
|
||||||
|
|
||||||
typedef struct SSortHandle SSortHandle;
|
typedef struct SSortHandle SSortHandle;
|
||||||
|
@ -99,6 +100,11 @@ int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetc
|
||||||
*/
|
*/
|
||||||
int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp);
|
int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int32_t tsortSetCompareGroupId(SSortHandle* pHandle, bool compareGroupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param pHandle
|
* @param pHandle
|
||||||
|
|
|
@ -523,7 +523,8 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) {
|
||||||
pInfo->pInputBlock, pTaskInfo->id.str);
|
pInfo->pInputBlock, pTaskInfo->id.str);
|
||||||
|
|
||||||
tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL);
|
tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL);
|
||||||
|
tsortSetCompareGroupId(pInfo->pSortHandle, true);
|
||||||
|
|
||||||
for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
|
for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) {
|
||||||
SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource));
|
SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource));
|
||||||
ps->param = pOperator->pDownstream[i];
|
ps->param = pOperator->pDownstream[i];
|
||||||
|
|
|
@ -86,6 +86,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
|
||||||
|
|
||||||
pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES);
|
pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES);
|
||||||
pSortHandle->cmpParam.orderInfo = pSortInfo;
|
pSortHandle->cmpParam.orderInfo = pSortInfo;
|
||||||
|
pSortHandle->cmpParam.cmpGroupId = false;
|
||||||
|
|
||||||
tsortSetComparFp(pSortHandle, msortComparFn);
|
tsortSetComparFp(pSortHandle, msortComparFn);
|
||||||
|
|
||||||
|
@ -374,6 +375,12 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) {
|
||||||
SSDataBlock* pLeftBlock = pLeftSource->src.pBlock;
|
SSDataBlock* pLeftBlock = pLeftSource->src.pBlock;
|
||||||
SSDataBlock* pRightBlock = pRightSource->src.pBlock;
|
SSDataBlock* pRightBlock = pRightSource->src.pBlock;
|
||||||
|
|
||||||
|
if (pParam->cmpGroupId) {
|
||||||
|
if (pLeftBlock->info.groupId != pRightBlock->info.groupId) {
|
||||||
|
return pLeftBlock->info.groupId < pRightBlock->info.groupId ? -1 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int32_t i = 0; i < pInfo->size; ++i) {
|
for(int32_t i = 0; i < pInfo->size; ++i) {
|
||||||
SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i);
|
SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i);
|
||||||
SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId);
|
SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId);
|
||||||
|
@ -680,6 +687,11 @@ int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsortSetCompareGroupId(SSortHandle* pHandle, bool compareGroupId) {
|
||||||
|
pHandle->cmpParam.cmpGroupId = compareGroupId;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
|
STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
|
||||||
if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) {
|
if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue