diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 532c35165be71541f650946ea10d691cb27bf84c..e8830e32f8feedd47f92219fc4efec03c12f4a7d 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -87,7 +87,8 @@ int32_t tBufferReserve(SBuffer *pBuffer, int64_t nData, void **ppData); int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SRow **ppRow); void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal); void tRowDestroy(SRow *pRow); -int32_t tRowMergeSort(SArray *aRowP, STSchema *pTSchema, int8_t flag); +void tRowSort(SArray *aRowP); +int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag); // SRowIter ================================ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 6d7c94b4a2af6293e7ebde58e39fe01fbb7c9bb1..ccba25873db7d468a02cce987e60b0d5454e29eb 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -527,7 +527,7 @@ static int32_t tRowPCmprFn(const void *p1, const void *p2) { return 0; } static void tRowPDestroy(SRow **ppRow) { tRowDestroy(*ppRow); } -static int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int32_t iStart, int32_t iEnd, int8_t flag) { +static int32_t tRowMergeImpl(SArray *aRowP, STSchema *pTSchema, int32_t iStart, int32_t iEnd, int8_t flag) { int32_t code = 0; int32_t nRow = iEnd - iStart; @@ -591,12 +591,14 @@ _exit: if (code) tRowDestroy(pRow); return code; } -int32_t tRowMergeSort(SArray *aRowP, STSchema *pTSchema, int8_t flag) { - if (aRowP->size <= 1) return 0; - - int32_t code = 0; +void tRowSort(SArray *aRowP) { + if (TARRAY_SIZE(aRowP) <= 1) return; taosArraySort(aRowP, tRowPCmprFn); +} + +int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag) { + int32_t code = 0; int32_t iStart = 0; while (iStart < aRowP->size) { @@ -612,7 +614,7 @@ int32_t tRowMergeSort(SArray *aRowP, STSchema *pTSchema, int8_t flag) { } if (iEnd - iStart > 1) { - code = tRowMerge(aRowP, pTSchema, iStart, iEnd, flag); + code = tRowMergeImpl(aRowP, pTSchema, iStart, iEnd, flag); } // the array is also changing, so the iStart just ++ instead of iEnd diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index a138b684d1b5877f9c2f356278b99e281070906a..ce7df059d9828658dd35be487be4c832f383e15f 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -1179,7 +1179,7 @@ int32_t insMergeTableDataCxt(SHashObj* pTableHash, SArray** pVgDataBlocks) { void* p = taosHashIterate(pTableHash, NULL); while (TSDB_CODE_SUCCESS == code && NULL != p) { STableDataCxt* pTableCxt = *(STableDataCxt**)p; - code = tRowMergeSort(pTableCxt->pData->aRowP, pTableCxt->pSchema, 0); + code = tRowMerge(pTableCxt->pData->aRowP, pTableCxt->pSchema, 0); if (TSDB_CODE_SUCCESS == code) { SVgroupDataCxt* pVgCxt = NULL; int32_t vgId = pTableCxt->pMeta->vgId;