SQLite

Check-in [6319ee1256]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid unnecessary cachedCellSize() calls in the cell partition adjustment phase of balance_nonroot().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | btree-opt2
Files: files | file ages | folders
SHA1: 6319ee1256b1f7c39dd39a536a39b77b3d10dcac
User & Date: drh 2015-06-23 16:00:24.052
Context
2015-06-23
17:09
Faster loading of cell pointers into the b.apCell array in balance_nonroot. (check-in: fda89b0512 user: drh tags: btree-opt2)
16:00
Avoid unnecessary cachedCellSize() calls in the cell partition adjustment phase of balance_nonroot(). (check-in: 6319ee1256 user: drh tags: btree-opt2)
15:36
Change pageInsertArray() and pageFreeArray() so that they use the CellArray object and compute cell sizes as needed, resulting in smaller and faster code. (check-in: f7f4181811 user: drh tags: btree-opt2)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223


7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238


7239
7240
7241
7242
7243
7244
7245
  */
  for(i=k-1; i>0; i--){
    int szRight = szNew[i];  /* Size of sibling on the right */
    int szLeft = szNew[i-1]; /* Size of sibling on the left */
    int r;              /* Index of right-most cell in left sibling */
    int d;              /* Index of first cell to the left of right sibling */

    while(1){
      r = cntNew[i-1] - 1;
      d = r + 1 - leafData;


      assert( d<nMaxCells );
      assert( r<nMaxCells );
      (void)cachedCellSize(&b, d);
      (void)cachedCellSize(&b, r);
      if( szRight!=0
       && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){
        break;
      }
      szRight += b.szCell[d] + 2;
      szLeft -= b.szCell[r] + 2;
      cntNew[i-1]--;
      if( cntNew[i-1] <= 0 ){
        rc = SQLITE_CORRUPT_BKPT;
        goto balance_cleanup;
      }


    }
    szNew[i] = szRight;
    szNew[i-1] = szLeft;
  }

  /* Sanity check:  For a non-corrupt database file one of the follwing
  ** must be true:







<
|
|
>
>


<







|




>
>







7214
7215
7216
7217
7218
7219
7220

7221
7222
7223
7224
7225
7226

7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
  */
  for(i=k-1; i>0; i--){
    int szRight = szNew[i];  /* Size of sibling on the right */
    int szLeft = szNew[i-1]; /* Size of sibling on the left */
    int r;              /* Index of right-most cell in left sibling */
    int d;              /* Index of first cell to the left of right sibling */


    r = cntNew[i-1] - 1;
    d = r + 1 - leafData;
    (void)cachedCellSize(&b, d);
    while(1){
      assert( d<nMaxCells );
      assert( r<nMaxCells );

      (void)cachedCellSize(&b, r);
      if( szRight!=0
       && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){
        break;
      }
      szRight += b.szCell[d] + 2;
      szLeft -= b.szCell[r] + 2;
      cntNew[i-1] = r;
      if( cntNew[i-1] <= 0 ){
        rc = SQLITE_CORRUPT_BKPT;
        goto balance_cleanup;
      }
      r--;
      d--;
    }
    szNew[i] = szRight;
    szNew[i-1] = szLeft;
  }

  /* Sanity check:  For a non-corrupt database file one of the follwing
  ** must be true: