From 7145bc5fc2bdb31bc6ab628263829afa3473aebd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Sun, 27 Jun 2021 03:53:30 +0800 Subject: [PATCH] [TD-4825] order by col after group-by --- src/util/src/tarray.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util/src/tarray.c b/src/util/src/tarray.c index a59e36d29f..15fda4ab51 100644 --- a/src/util/src/tarray.c +++ b/src/util/src/tarray.c @@ -279,9 +279,15 @@ static void taosArrayQuicksortHelper(SArray *pArray, int low, int high, __ext_co } static void taosArrayQuickSort(SArray* pArray, __ext_compar_fn_t fn, const void *param) { - return taosArrayQuicksortHelper(pArray, 0, taosArrayGetSize(pArray) - 1, fn, param); + if (pArray->size <= 0) { + return; + } + taosArrayQuicksortHelper(pArray, 0, taosArrayGetSize(pArray) - 1, fn, param); } static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void *param) { + if (pArray->size <= 0) { + return; + } for (int i = 1; i <= pArray->size - 1; ++i) { for (int j = i; j > 0; --j) { if (fn(taosArrayGetP(pArray, j), taosArrayGetP(pArray, j - 1), param) == -1) { @@ -294,9 +300,12 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void } } } + return; } +// order array void taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void *param) { - return taosArrayGetSize(pArray) > 8 ? + taosArrayGetSize(pArray) > 8 ? taosArrayQuickSort(pArray, fn, param) : taosArrayInsertSort(pArray, fn, param); } +//TODO(yihaoDeng) order array -- GitLab