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

Overview
Comment:Handle calls to lsm_work() with the nPage parameter set to not greater than zero. Remove some dead code.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | block-redirects
Files: files | file ages | folders
SHA1: 520f3729b832320b94659181591ba0a2481722ca
User & Date: dan 2013-01-26 20:18:38.522
Context
2013-01-28
08:56
Merge block-redirects branch with trunk. This changes the lsm file format. check-in: 647229e983 user: dan tags: trunk
2013-01-26
20:18
Handle calls to lsm_work() with the nPage parameter set to not greater than zero. Remove some dead code. Leaf check-in: 520f3729b8 user: dan tags: block-redirects
19:17
Fix problems with redirected blocks in compressed databases. check-in: 930b7e4507 user: dan tags: block-redirects
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/lsm_sorted.c.
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
}

/*
** Create a new free-list only top-level segment. Return LSM_OK if successful
** or an LSM error code if some error occurs.
*/
static int sortedNewFreelistOnly(lsm_db *pDb){
  int rc;
  Level *pLvl;

  pLvl = pDb->pWorker->pLevel;
  if( pLvl->pNext!=0 || pLvl->nRight==0 ){
    pLvl = 0;
  }

  rc = sortedNewToplevel(pDb, TREE_NONE, 0);
  if( 0 && rc==LSM_OK && pLvl ){
    Level *pNew = pDb->pWorker->pLevel;
    assert( pNew->pNext==pLvl );

    if( pLvl->pSplitKey==0 ){
      sortedSplitkey(pDb, pLvl, &rc);
    }
    if( rc==LSM_OK && pLvl->iSplitTopic==0 ){
      /* Add the new top-level to the rhs of pLvl. */
      Merge *pMerge;

      Segment *aRhs = (Segment *)lsmMallocZeroRc(pDb->pEnv, 
          sizeof(Segment) * (pLvl->nRight + 1), &rc
      );
      if( rc==LSM_OK ){
        memcpy(&aRhs[1], pLvl->aRhs, sizeof(Segment) * pLvl->nRight);
        aRhs[0] = pNew->lhs;
        lsmFree(pDb->pEnv, pLvl->aRhs);
        pLvl->aRhs = aRhs;
        pLvl->nRight++;
      }

      /* Also add an entry to the Merge object */
      pMerge = (Merge *)lsmMallocZeroRc(pDb->pEnv, 
          sizeof(Merge) + sizeof(MergeInput)*(pLvl->pMerge->nInput+1), &rc
      );
      if( rc==LSM_OK ){
        memcpy(pMerge, pLvl->pMerge, sizeof(Merge));
        pMerge->aInput = (MergeInput *)&pMerge[1];
        memcpy(&pMerge->aInput[1], pLvl->pMerge->aInput, 
            sizeof(MergeInput)*(pLvl->pMerge->nInput)
        );
        pMerge->aInput[0].iPg = aRhs[0].iFirst;
        pMerge->aInput[0].iCell = 0;
        pMerge->nInput++;
        lsmFree(pDb->pEnv, pLvl->pMerge);
        pLvl->pMerge = pMerge;

        sortedFreeLevel(pDb->pEnv, pNew);
        pDb->pWorker->pLevel = pLvl;
      }
    }
  }

  return rc;
}

int lsmSaveWorker(lsm_db *pDb, int bFlush){
  Snapshot *p = pDb->pWorker;
  if( p->freelist.nEntry>pDb->nMaxFreelist ){
    int rc = sortedNewFreelistOnly(pDb);
    if( rc!=LSM_OK ) return rc;







<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







5057
5058
5059
5060
5061
5062
5063








5064













































5065
5066
5067
5068
5069
5070
5071
}

/*
** Create a new free-list only top-level segment. Return LSM_OK if successful
** or an LSM error code if some error occurs.
*/
static int sortedNewFreelistOnly(lsm_db *pDb){








  return sortedNewToplevel(pDb, TREE_NONE, 0);













































}

int lsmSaveWorker(lsm_db *pDb, int bFlush){
  Snapshot *p = pDb->pWorker;
  if( p->freelist.nEntry>pDb->nMaxFreelist ){
    int rc = sortedNewFreelistOnly(pDb);
    if( rc!=LSM_OK ) return rc;
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255



5256
5257
5258
5259
5260
5261
5262
5263
5264

5265
5266
5267
5268
5269
5270
5271
    *pnWrite = 0;
  }
  assert( pDb->pWorker==0 );
  return rc;
}

static int doLsmWork(lsm_db *pDb, int nMerge, int nPage, int *pnWrite){
  int rc;
  int nWrite = 0;
  int bCkpt = 0;

  assert( nMerge>=1 );



  do {
    int nThis = 0;
    bCkpt = 0;
    rc = doLsmSingleWork(pDb, 0, nMerge, nPage-nWrite, &nThis, &bCkpt);
    nWrite += nThis;
    if( rc==LSM_OK && bCkpt ){
      rc = lsm_checkpoint(pDb, 0);
    }
  }while( rc==LSM_OK && (nWrite<nPage && bCkpt) );


  if( pnWrite ){
    if( rc==LSM_OK ){
      *pnWrite = nWrite;
    }else{
      *pnWrite = 0;
    }







|
|
<


>
>
>
|
|
|
|
|
|
|
|
|
>







5191
5192
5193
5194
5195
5196
5197
5198
5199

5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
    *pnWrite = 0;
  }
  assert( pDb->pWorker==0 );
  return rc;
}

static int doLsmWork(lsm_db *pDb, int nMerge, int nPage, int *pnWrite){
  int rc = LSM_OK;                /* Return code */
  int nWrite = 0;                 /* Number of pages written */


  assert( nMerge>=1 );

  if( nPage>0 ){
    int bCkpt = 0;
    do {
      int nThis = 0;
      bCkpt = 0;
      rc = doLsmSingleWork(pDb, 0, nMerge, nPage-nWrite, &nThis, &bCkpt);
      nWrite += nThis;
      if( rc==LSM_OK && bCkpt ){
        rc = lsm_checkpoint(pDb, 0);
      }
    }while( rc==LSM_OK && (nWrite<nPage && bCkpt) );
  }

  if( pnWrite ){
    if( rc==LSM_OK ){
      *pnWrite = nWrite;
    }else{
      *pnWrite = 0;
    }