Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the optimization to avoid some unnecessary calls to sqlite3VdbeRecordUnpack() added to the trunk by [707ea170b3]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | threads |
Files: | files | file ages | folders |
SHA1: |
fc4d04e6b039ea5aeb47739e38c5926e |
User & Date: | dan 2014-03-29 06:27:35.162 |
Context
2014-03-29
| ||
09:34 | Fix a problem in vdbesort.c causing spurious SQLITE_NOMEM errors when using memsys3 or memsys5. (check-in: a683c05f62 user: dan tags: threads) | |
06:27 | Add the optimization to avoid some unnecessary calls to sqlite3VdbeRecordUnpack() added to the trunk by [707ea170b3]. (check-in: fc4d04e6b0 user: dan tags: threads) | |
2014-03-28
| ||
19:18 | Merge latest changes from orderby-planning branch. (check-in: 4c7fb54234 user: dan tags: threads) | |
Changes
Changes to src/vdbesort.c.
︙ | ︙ | |||
1048 1049 1050 1051 1052 1053 1054 | int iPrev = pMerger->aTree[1];/* Index of iterator to advance */ int i; /* Index of aTree[] to recalculate */ /* Advance the current iterator */ rc = vdbeSorterIterNext(&pMerger->aIter[iPrev]); /* Update contents of aTree[] */ | > > > > > > > > > > > > | > > > > > > > | > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > > | 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | int iPrev = pMerger->aTree[1];/* Index of iterator to advance */ int i; /* Index of aTree[] to recalculate */ /* Advance the current iterator */ rc = vdbeSorterIterNext(&pMerger->aIter[iPrev]); /* Update contents of aTree[] */ if( rc==SQLITE_OK ){ int i; /* Index of aTree[] to recalculate */ VdbeSorterIter *pIter1; /* First iterator to compare */ VdbeSorterIter *pIter2; /* Second iterator to compare */ u8 *pKey2; /* To pIter2->aKey, or 0 if record cached */ /* Find the first two iterators to compare. The one that was just ** advanced (iPrev) and the one next to it in the array. */ pIter1 = &pMerger->aIter[(iPrev & 0xFFFE)]; pIter2 = &pMerger->aIter[(iPrev | 0x0001)]; pKey2 = pIter2->aKey; for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){ /* Compare pIter1 and pIter2. Store the result in variable iRes. */ int iRes; if( pIter1->pFile==0 ){ iRes = +1; }else if( pIter2->pFile==0 ){ iRes = -1; }else{ vdbeSorterCompare(pThread, 0, pIter1->aKey, pIter1->nKey, pKey2, pIter2->nKey, &iRes ); } /* If pIter1 contained the smaller value, set aTree[i] to its index. ** Then set pIter2 to the next iterator to compare to pIter1. In this ** case there is no cache of pIter2 in pThread->pUnpacked, so set ** pKey2 to point to the record belonging to pIter2. ** ** Alternatively, if pIter2 contains the smaller of the two values, ** set aTree[i] to its index and update pIter1. If vdbeSorterCompare() ** was actually called above, then pThread->pUnpacked now contains ** a value equivalent to pIter2. So set pKey2 to NULL to prevent ** vdbeSorterCompare() from decoding pIter2 again. ** ** If the two values were equal, then the value from the oldest ** PMA should be considered smaller. The VdbeSorter.aIter[] array ** is sorted from oldest to newest, so pIter1 contains older values ** than pIter2 iff (pIter1<pIter2). */ if( iRes<0 || (iRes==0 && pIter1<pIter2) ){ pMerger->aTree[i] = (int)(pIter1 - pMerger->aIter); pIter2 = &pMerger->aIter[ pMerger->aTree[i ^ 0x0001] ]; pKey2 = pIter2->aKey; }else{ if( pIter1->pFile ) pKey2 = 0; pMerger->aTree[i] = (int)(pIter2 - pMerger->aIter); pIter1 = &pMerger->aIter[ pMerger->aTree[i ^ 0x0001] ]; } } *pbEof = (pMerger->aIter[pMerger->aTree[1]].pFile==0); } return rc; } /* ** The main routine for sorter-thread operations. */ static void *vdbeSorterThreadMain(void *pCtx){ |
︙ | ︙ |