Explorar o código

HPCC-13886 Use merge sort in preference to stable quick sort

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=10) %!d(string=hai) anos
pai
achega
5741ecb363
Modificáronse 4 ficheiros con 12 adicións e 5 borrados
  1. 1 1
      ecl/hthor/hthor.cpp
  2. 2 2
      roxie/ccd/ccdserver.cpp
  3. 8 1
      system/jlib/jsort.hpp
  4. 1 1
      thorlcr/thorutil/thmem.cpp

+ 1 - 1
ecl/hthor/hthor.cpp

@@ -2521,7 +2521,7 @@ bool CHThorGroupDedupAllActivity::calcNextDedupAll()
         MemoryAttr indexbuff(max*sizeof(void *));
         void ** temp = (void **)indexbuff.bufferBase();
         void ** rows = (void * *)group.getArray();
-        qsortvecstableinplace(rows, max, *primaryCompare, temp);
+        msortvecstableinplace(rows, max, *primaryCompare, temp);
         unsigned first = 0;
         for (unsigned idx = 1; idx < max; idx++)
         {

+ 2 - 2
roxie/ccd/ccdserver.cpp

@@ -6650,7 +6650,7 @@ public:
             MemoryAttr indexbuff(max*sizeof(void *));
             void ** temp = (void **)indexbuff.bufferBase();
             void * *rows = const_cast<void * *>(group.getArray());
-            qsortvecstableinplace(rows, max, *primaryCompare, temp);
+            msortvecstableinplace(rows, max, *primaryCompare, temp);
             unsigned first = 0;
             for (unsigned idx = 1; idx < max; idx++)
             {
@@ -16967,7 +16967,7 @@ public:
                             MemoryAttr tempAttr(rightord*sizeof(void **)); // Temp storage for stable sort. This should probably be allocated from roxiemem
                             void **temp = (void **) tempAttr.bufferBase();
                             void **_rows = const_cast<void * *>(rightset.getArray());
-                            qsortvecstableinplace(_rows, rightord, *helper.queryCompareRight(), temp);
+                            msortvecstableinplace(_rows, rightord, *helper.queryCompareRight(), temp);
                         }
                     }
                     table.setown(new ManyLookupTable(rightset, helper));  // NOTE - takes ownership of rightset

+ 8 - 1
system/jlib/jsort.hpp

@@ -95,7 +95,14 @@ extern jlib_decl bool heap_push_up(unsigned c, unsigned * heap, const void ** ro
 
 
 
-
+inline void parsortvecstableinplace(void ** rows, size32_t n, const ICompare & compare, void ** stableTablePtr, unsigned maxCores=0)
+{
+#ifdef _USE_TBB
+    parmsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
+#else
+    parqsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
+#endif
+}
 
 
 

+ 1 - 1
thorlcr/thorutil/thmem.cpp

@@ -508,7 +508,7 @@ void CThorExpandingRowArray::doSort(rowidx_t n, void **const rows, ICompare &com
             dbgassertex(NULL != stableTable);
             stableTablePtr = stableTable;
         }
-        parqsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
+        parsortvecstableinplace(rows, n, compare, stableTablePtr, maxCores);
     }
     else
         parqsortvec((void **const)rows, n, compare, maxCores);