From: drh Date: Wed, 2 Apr 2014 14:38:14 +0000 (+0000) Subject: Change the name of the SorterThread object to "SortSubtask" to avoid confusion X-Git-Tag: version-3.8.7~132^2~87 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d8f56296b1101784d2223f18808d50a245c8fec;p=thirdparty%2Fsqlite.git Change the name of the SorterThread object to "SortSubtask" to avoid confusion with the SQLiteThread object. FossilOrigin-Name: 4ee2d910fbbed8d4def15e4e99ee225839f3a739 --- diff --git a/manifest b/manifest index d0ef35d91d..8bc41fb375 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\ssorting\sdata\sfor\sa\sCREATE\sINDEX\sstatement\sin\ssingle-threaded\smode,\sassume\sthat\skeys\sare\sdelivered\sto\sthe\ssorter\sin\sprimary\skey\sorder.\sAlso\sfix\svarious\scomments\sthat\shad\sfallen\sout\sof\sdate. -D 2014-04-01T18:41:51.759 +C Change\sthe\sname\sof\sthe\sSorterThread\sobject\sto\s"SortSubtask"\sto\savoid\sconfusion\nwith\sthe\sSQLiteThread\sobject. +D 2014-04-02T14:38:14.734 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in ad0921c4b2780d01868cf69b419a4f102308d125 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -286,7 +286,7 @@ F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 F src/vdbeaux.c d8dc38965507a34b0e150c0d7fc82b02f8cf25ea F src/vdbeblob.c 15377abfb59251bccedd5a9c7d014a895f0c04aa F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447 -F src/vdbesort.c be494ad4a1cb5845c51c9bc25b8ec151f504d49c +F src/vdbesort.c 0cb83fc36f8a56cc6e4ecdefc3c7d4155169cef2 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8 @@ -1161,7 +1161,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 643c86a056168e39fcb7f39b8a72731f1eb246db -R c2ac1c0b48f44ef7c812322485a83f86 -U dan -Z 23ba0058a55a91ed976e2b1f4e943278 +P 821d1ac4504243fa13b9e3c0d56361ad9fb80d78 +R 2283517ddbfd0881db16b2410c51a15c +U drh +Z e6ea0be46d70fe73f5ea59fa8b577076 diff --git a/manifest.uuid b/manifest.uuid index 823d08f629..0fe5750cf3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -821d1ac4504243fa13b9e3c0d56361ad9fb80d78 \ No newline at end of file +4ee2d910fbbed8d4def15e4e99ee225839f3a739 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 81b2ff5c2b..ff315494e6 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -20,57 +20,57 @@ typedef struct VdbeSorterIter VdbeSorterIter; -typedef struct SorterThread SorterThread; +typedef struct SortSubtask SortSubtask; typedef struct SorterRecord SorterRecord; typedef struct SorterMerger SorterMerger; typedef struct FileWriter FileWriter; /* -** Candidate values for SorterThread.eWork +** Candidate values for SortSubtask.eWork */ -#define SORTER_THREAD_SORT 1 -#define SORTER_THREAD_TO_PMA 2 -#define SORTER_THREAD_CONS 3 +#define SORTER_THREAD_SORT 1 /* Sort records on pList */ +#define SORTER_THREAD_TO_PMA 2 /* Xfer pList to Packed-Memory-Array pFile */ +#define SORTER_THREAD_CONS 3 /* Consolidate multiple PMAs */ /* ** Much of the work performed in this module to sort the list of records is ** broken down into smaller units that may be peformed in parallel. In order ** to perform such a unit of work, an instance of the following structure -** is configured and passed to vdbeSorterThreadMain() - either directly by +** is configured and passed to vdbeSortSubtaskMain() - either directly by ** the main thread or via a background thread. ** -** Exactly SorterThread.nThread instances of this structure are allocated +** Exactly SortSubtask.nThread instances of this structure are allocated ** as part of each VdbeSorter object. Instances are never allocated any other -** way. SorterThread.nThread is set to the number of worker threads allowed +** way. SortSubtask.nThread is set to the number of worker threads allowed ** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread). ** -** When a background thread is launched to perform work, SorterThread.bDone -** is set to 0 and the SorterThread.pThread variable set to point to the -** thread handle. SorterThread.bDone is set to 1 (to indicate to the main -** thread that joining SorterThread.pThread will not block) before the thread -** exits. SorterThread.pThread and bDone are always cleared after the +** When a background thread is launched to perform work, SortSubtask.bDone +** is set to 0 and the SortSubtask.pThread variable set to point to the +** thread handle. SortSubtask.bDone is set to 1 (to indicate to the main +** thread that joining SortSubtask.pThread will not block) before the thread +** exits. SortSubtask.pThread and bDone are always cleared after the ** background thread has been joined. ** -** One object (specifically, VdbeSorter.aThread[SorterThread.nThread-1]) +** One object (specifically, VdbeSorter.aThread[SortSubtask.nThread-1]) ** is reserved for the foreground thread. ** -** The nature of the work performed is determined by SorterThread.eWork, +** The nature of the work performed is determined by SortSubtask.eWork, ** as follows: ** ** SORTER_THREAD_SORT: -** Sort the linked list of records at SorterThread.pList. +** Sort the linked list of records at SortSubtask.pList. ** ** SORTER_THREAD_TO_PMA: -** Sort the linked list of records at SorterThread.pList, and write -** the results to a new PMA in temp file SorterThread.pTemp1. Open +** Sort the linked list of records at SortSubtask.pList, and write +** the results to a new PMA in temp file SortSubtask.pTemp1. Open ** the temp file if it is not already open. ** ** SORTER_THREAD_CONS: -** Merge existing PMAs until SorterThread.nConsolidate or fewer -** remain in temp file SorterThread.pTemp1. +** Merge existing PMAs until SortSubtask.nConsolidate or fewer +** remain in temp file SortSubtask.pTemp1. */ -struct SorterThread { +struct SortSubtask { SQLiteThread *pThread; /* Thread handle, or NULL */ int bDone; /* Set to true by pThread when finished */ @@ -182,7 +182,7 @@ struct VdbeSorter { int nMemory; /* Size of aMemory allocation in bytes */ int iPrev; /* Previous thread used to flush PMA */ int nThread; /* Size of aThread[] array */ - SorterThread aThread[1]; + SortSubtask aThread[1]; }; /* @@ -427,7 +427,7 @@ static int vdbeSorterIterNext(VdbeSorterIter *pIter){ ** PMA is empty). */ static int vdbeSorterIterInit( - SorterThread *pThread, /* Thread context */ + SortSubtask *pThread, /* Thread context */ i64 iStart, /* Start offset in pThread->pTemp1 */ VdbeSorterIter *pIter, /* Iterator to populate */ i64 *pnByte /* IN/OUT: Increment this value by PMA size */ @@ -501,7 +501,7 @@ static int vdbeSorterIterInit( ** to SQLITE_NOMEM. */ static int vdbeSorterCompare( - SorterThread *pThread, /* Thread context (for pKeyInfo) */ + SortSubtask *pThread, /* Thread context (for pKeyInfo) */ const void *pKey1, int nKey1, /* Left side of comparison */ const void *pKey2, int nKey2 /* Right side of comparison */ ){ @@ -518,7 +518,7 @@ static int vdbeSorterCompare( ** value to recalculate. */ static int vdbeSorterDoCompare( - SorterThread *pThread, + SortSubtask *pThread, SorterMerger *pMerger, int iOut ){ @@ -547,7 +547,7 @@ static int vdbeSorterDoCompare( iRes = i1; }else{ int res; - assert( pThread->pUnpacked!=0 ); /* allocated in vdbeSorterThreadMain() */ + assert( pThread->pUnpacked!=0 ); /* allocated in vdbeSortSubtaskMain() */ res = vdbeSorterCompare( pThread, p1->aKey, p1->nKey, p2->aKey, p2->nKey ); @@ -578,7 +578,7 @@ int sqlite3VdbeSorterInit(sqlite3 *db, int nField, VdbeCursor *pCsr){ assert( pCsr->pKeyInfo && pCsr->pBt==0 ); szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nField-1)*sizeof(CollSeq*); - sz = sizeof(VdbeSorter) + nWorker * sizeof(SorterThread); + sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask); pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo); pCsr->pSorter = pSorter; @@ -593,7 +593,7 @@ int sqlite3VdbeSorterInit(sqlite3 *db, int nField, VdbeCursor *pCsr){ pSorter->nThread = nWorker + 1; for(i=0; inThread; i++){ - SorterThread *pThread = &pSorter->aThread[i]; + SortSubtask *pThread = &pSorter->aThread[i]; pThread->pKeyInfo = pKeyInfo; pThread->pVfs = db->pVfs; pThread->pgsz = pgsz; @@ -636,7 +636,7 @@ static void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){ ** Free all resources owned by the object indicated by argument pThread. All ** fields of *pThread are zeroed before returning. */ -static void vdbeSorterThreadCleanup(sqlite3 *db, SorterThread *pThread){ +static void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pThread){ sqlite3DbFree(db, pThread->pUnpacked); pThread->pUnpacked = 0; if( pThread->aListMemory==0 ){ @@ -660,7 +660,7 @@ static int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){ int rc = rcin; int i; for(i=0; inThread; i++){ - SorterThread *pThread = &pSorter->aThread[i]; + SortSubtask *pThread = &pSorter->aThread[i]; if( pThread->pThread ){ void *pRet; int rc2 = sqlite3ThreadJoin(pThread->pThread, &pRet); @@ -725,8 +725,8 @@ void sqlite3VdbeSorterReset(sqlite3 *db, VdbeSorter *pSorter){ int i; vdbeSorterJoinAll(pSorter, SQLITE_OK); for(i=0; inThread; i++){ - SorterThread *pThread = &pSorter->aThread[i]; - vdbeSorterThreadCleanup(db, pThread); + SortSubtask *pThread = &pSorter->aThread[i]; + vdbeSortSubtaskCleanup(db, pThread); } if( pSorter->aMemory==0 ){ vdbeSorterRecordFree(0, pSorter->pRecord); @@ -776,7 +776,7 @@ static int vdbeSorterOpenTempFile(sqlite3_vfs *pVfs, sqlite3_file **ppFile){ ** Set *ppOut to the head of the new list. */ static void vdbeSorterMerge( - SorterThread *pThread, /* Calling thread context */ + SortSubtask *pThread, /* Calling thread context */ SorterRecord *p1, /* First list to merge */ SorterRecord *p2, /* Second list to merge */ SorterRecord **ppOut /* OUT: Head of merged list */ @@ -810,7 +810,7 @@ static void vdbeSorterMerge( ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if ** an error occurs. */ -static int vdbeSorterSort(SorterThread *pThread){ +static int vdbeSorterSort(SortSubtask *pThread){ int i; SorterRecord **aSlot; SorterRecord *p; @@ -974,7 +974,7 @@ static int vdbeSorterExtendFile(sqlite3_file *pFile, i64 nByte){ ** Each record consists of a varint followed by a blob of data (the ** key). The varint is the number of bytes in the blob of data. */ -static int vdbeSorterListToPMA(SorterThread *pThread){ +static int vdbeSorterListToPMA(SortSubtask *pThread){ int rc = SQLITE_OK; /* Return code */ FileWriter writer; /* Object used to write to the file */ @@ -1025,7 +1025,7 @@ static int vdbeSorterListToPMA(SorterThread *pThread){ ** Return SQLITE_OK if successful or an error code if an error occurs. */ static int vdbeSorterNext( - SorterThread *pThread, + SortSubtask *pThread, SorterMerger *pMerger, int *pbEof ){ @@ -1095,9 +1095,9 @@ static int vdbeSorterNext( /* ** The main routine for sorter-thread operations. */ -static void *vdbeSorterThreadMain(void *pCtx){ +static void *vdbeSortSubtaskMain(void *pCtx){ int rc = SQLITE_OK; - SorterThread *pThread = (SorterThread*)pCtx; + SortSubtask *pThread = (SortSubtask*)pCtx; assert( pThread->eWork==SORTER_THREAD_SORT || pThread->eWork==SORTER_THREAD_TO_PMA @@ -1216,8 +1216,8 @@ static void *vdbeSorterThreadMain(void *pCtx){ ** Run the activity scheduled by the object passed as the only argument ** in the current thread. */ -static int vdbeSorterRunThread(SorterThread *pThread){ - int rc = SQLITE_PTR_TO_INT( vdbeSorterThreadMain((void*)pThread) ); +static int vdbeSorterRunThread(SortSubtask *pThread){ + int rc = SQLITE_PTR_TO_INT( vdbeSortSubtaskMain((void*)pThread) ); assert( pThread->bDone ); pThread->bDone = 0; return rc; @@ -1233,7 +1233,7 @@ static int vdbeSorterFlushPMA(sqlite3 *db, const VdbeCursor *pCsr, int bFg){ VdbeSorter *pSorter = pCsr->pSorter; int rc = SQLITE_OK; int i; - SorterThread *pThread = 0; /* Thread context used to create new PMA */ + SortSubtask *pThread = 0; /* Thread context used to create new PMA */ int nWorker = (pSorter->nThread-1); pSorter->bUsePMA = 1; @@ -1287,7 +1287,7 @@ static int vdbeSorterFlushPMA(sqlite3 *db, const VdbeCursor *pCsr, int bFg){ pSorter->nMemory = sqlite3MallocSize(pSorter->aMemory); } } - rc = sqlite3ThreadCreate(&pThread->pThread, vdbeSorterThreadMain, pCtx); + rc = sqlite3ThreadCreate(&pThread->pThread, vdbeSortSubtaskMain, pCtx); }else #endif { @@ -1422,7 +1422,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ ** from the in-memory list. */ if( pSorter->bUsePMA==0 ){ if( pSorter->pRecord ){ - SorterThread *pThread = &pSorter->aThread[0]; + SortSubtask *pThread = &pSorter->aThread[0]; *pbEof = 0; pThread->pList = pSorter->pRecord; pThread->eWork = SORTER_THREAD_SORT; @@ -1451,7 +1451,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ if( vdbeSorterCountPMA(pSorter)>SORTER_MAX_MERGE_COUNT ){ int i; for(i=0; rc==SQLITE_OK && inThread; i++){ - SorterThread *pThread = &pSorter->aThread[i]; + SortSubtask *pThread = &pSorter->aThread[i]; if( pThread->pTemp1 ){ pThread->nConsolidate = SORTER_MAX_MERGE_COUNT / pSorter->nThread; pThread->eWork = SORTER_THREAD_CONS; @@ -1459,7 +1459,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ #if SQLITE_MAX_WORKER_THREADS>0 if( i<(pSorter->nThread-1) ){ void *pCtx = (void*)pThread; - rc = sqlite3ThreadCreate(&pThread->pThread,vdbeSorterThreadMain,pCtx); + rc = sqlite3ThreadCreate(&pThread->pThread,vdbeSortSubtaskMain,pCtx); }else #endif { @@ -1492,7 +1492,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ for(iThread=0; iThreadnThread; iThread++){ int iPMA; i64 iReadOff = 0; - SorterThread *pThread = &pSorter->aThread[iThread]; + SortSubtask *pThread = &pSorter->aThread[iThread]; for(iPMA=0; iPMAnPMA && rc==SQLITE_OK; iPMA++){ i64 nDummy = 0; VdbeSorterIter *pIter = &pMerger->aIter[iIter++];