]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change some LSM code internal typenames from "Blob" and "Pgno" to "LsmBlob"
authordan <dan@noemail.net>
Wed, 13 Dec 2017 15:32:33 +0000 (15:32 +0000)
committerdan <dan@noemail.net>
Wed, 13 Dec 2017 15:32:33 +0000 (15:32 +0000)
and "LsmPgno". This allows the LSM code to be compiled as a single unit with
sqlite3.c.

FossilOrigin-Name: 30bf38d589adf0b2eb613e184ffb03ed7e625736cb04fd5c341328f72bc5ef4d

ext/lsm1/lsmInt.h
ext/lsm1/lsm_ckpt.c
ext/lsm1/lsm_file.c
ext/lsm1/lsm_main.c
ext/lsm1/lsm_sorted.c
manifest
manifest.uuid

index b346d8ddedea86c6ff4d3b7908f305e7d6a3fbe1..0f822e47932f28074cfdd8909a6d81078707663d 100644 (file)
@@ -110,7 +110,7 @@ typedef unsigned long long int u64;
 #endif
 
 /* A page number is a 64-bit integer. */
-typedef i64 Pgno;
+typedef i64 LsmPgno;
 
 #ifdef LSM_DEBUG
 int lsmErrorBkpt(int);
@@ -402,9 +402,9 @@ struct lsm_db {
 };
 
 struct Segment {
-  Pgno iFirst;                     /* First page of this run */
-  Pgno iLastPg;                    /* Last page of this run */
-  Pgno iRoot;                      /* Root page number (if any) */
+  LsmPgno iFirst;                  /* First page of this run */
+  LsmPgno iLastPg;                 /* Last page of this run */
+  LsmPgno iRoot;                   /* Root page number (if any) */
   int nSize;                       /* Size of this run in pages */
 
   Redirect *pRedirect;             /* Block redirects (or NULL) */
@@ -456,7 +456,7 @@ struct Level {
 **   output segment.
 */
 struct MergeInput {
-  Pgno iPg;                       /* Page on which next input is stored */
+  LsmPgno iPg;                    /* Page on which next input is stored */
   int iCell;                      /* Cell containing next input to merge */
 };
 struct Merge {
@@ -465,7 +465,7 @@ struct Merge {
   MergeInput splitkey;            /* Location in file of current splitkey */
   int nSkip;                      /* Number of separators entries to skip */
   int iOutputOff;                 /* Write offset on output page */
-  Pgno iCurrentPtr;               /* Current pointer value */
+  LsmPgno iCurrentPtr;            /* Current pointer value */
 };
 
 /* 
@@ -579,10 +579,10 @@ struct Snapshot {
   Redirect redirect;              /* Block redirection array */
 
   /* Used by worker snapshots only */
-  int nBlock;                     /* Number of blocks in database file */
-  Pgno aiAppend[LSM_APPLIST_SZ];  /* Append point list */
-  Freelist freelist;              /* Free block list */
-  u32 nWrite;                     /* Total number of pages written to disk */
+  int nBlock;                        /* Number of blocks in database file */
+  LsmPgno aiAppend[LSM_APPLIST_SZ];  /* Append point list */
+  Freelist freelist;                 /* Free block list */
+  u32 nWrite;                        /* Total number of pages written to disk */
 };
 #define LSM_INITIAL_SNAPSHOT_ID 11
 
@@ -710,7 +710,7 @@ void lsmFsSetPageSize(FileSystem *, int);
 int lsmFsFileid(lsm_db *pDb, void **ppId, int *pnId);
 
 /* Creating, populating, gobbling and deleting sorted runs. */
-void lsmFsGobble(lsm_db *, Segment *, Pgno *, int);
+void lsmFsGobble(lsm_db *, Segment *, LsmPgno *, int);
 int lsmFsSortedDelete(FileSystem *, Snapshot *, int, Segment *);
 int lsmFsSortedFinish(FileSystem *, Segment *);
 int lsmFsSortedAppend(FileSystem *, Snapshot *, Level *, int, Page **);
@@ -727,14 +727,14 @@ void lsmSortedSplitkey(lsm_db *, Level *, int *);
 
 /* Reading sorted run content. */
 int lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg);
-int lsmFsDbPageGet(FileSystem *, Segment *, Pgno, Page **);
+int lsmFsDbPageGet(FileSystem *, Segment *, LsmPgno, Page **);
 int lsmFsDbPageNext(Segment *, Page *, int eDir, Page **);
 
 u8 *lsmFsPageData(Page *, int *);
 int lsmFsPageRelease(Page *);
 int lsmFsPagePersist(Page *);
 void lsmFsPageRef(Page *);
-Pgno lsmFsPageNumber(Page *);
+LsmPgno lsmFsPageNumber(Page *);
 
 int lsmFsNRead(FileSystem *);
 int lsmFsNWrite(FileSystem *);
@@ -748,7 +748,7 @@ int lsmFsDbPageIsLast(Segment *pSeg, Page *pPg);
 int lsmFsIntegrityCheck(lsm_db *);
 #endif
 
-Pgno lsmFsRedirectPage(FileSystem *, Redirect *, Pgno);
+LsmPgno lsmFsRedirectPage(FileSystem *, Redirect *, LsmPgno);
 
 int lsmFsPageWritable(Page *);
 
@@ -768,8 +768,8 @@ int lsmFsSyncDb(FileSystem *, int);
 void lsmFsFlushWaiting(FileSystem *, int *);
 
 /* Used by lsm_info(ARRAY_STRUCTURE) and lsm_config(MMAP) */
-int lsmInfoArrayStructure(lsm_db *pDb, int bBlock, Pgno iFirst, char **pzOut);
-int lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut);
+int lsmInfoArrayStructure(lsm_db *pDb, int bBlock, LsmPgno iFirst, char **pz);
+int lsmInfoArrayPages(lsm_db *pDb, LsmPgno iFirst, char **pzOut);
 int lsmConfigMmap(lsm_db *pDb, int *piParam);
 
 int lsmEnvOpen(lsm_env *, const char *, int, lsm_file **);
@@ -785,7 +785,7 @@ void lsmEnvSleep(lsm_env *, int);
 
 int lsmFsReadSyncedId(lsm_db *db, int, i64 *piVal);
 
-int lsmFsSegmentContainsPg(FileSystem *pFS, Segment *, Pgno, int *);
+int lsmFsSegmentContainsPg(FileSystem *pFS, Segment *, LsmPgno, int *);
 
 void lsmFsPurgeCache(FileSystem *);
 
@@ -796,7 +796,7 @@ void lsmFsPurgeCache(FileSystem *);
 /* 
 ** Functions from file "lsm_sorted.c".
 */
-int lsmInfoPageDump(lsm_db *, Pgno, int, char **);
+int lsmInfoPageDump(lsm_db *, LsmPgno, int, char **);
 void lsmSortedCleanup(lsm_db *);
 int lsmSortedAutoWork(lsm_db *, int nUnit);
 
index cf4c55bf84169fc4a99fe94ed49db4c796a97834..ba92a823cf9274eaf842438d924050b93f8d9796 100644 (file)
@@ -389,7 +389,7 @@ static void ckptExportAppendlist(
   int *pRc                        /* IN/OUT: Error code */
 ){
   int i;
-  Pgno *aiAppend = db->pWorker->aiAppend;
+  LsmPgno *aiAppend = db->pWorker->aiAppend;
 
   for(i=0; i<LSM_APPLIST_SZ; i++){
     ckptAppend64(p, piOut, aiAppend[i], pRc);
index 4001aac978390589b9915ced05f8bce0872bbeb8..1dcdd05d997895a8d136bed90af8c9361c1d48f2 100644 (file)
@@ -269,7 +269,7 @@ struct FileSystem {
 struct Page {
   u8 *aData;                      /* Buffer containing page data */
   int nData;                      /* Bytes of usable data at aData[] */
-  Pgno iPg;                       /* Page number */
+  LsmPgno iPg;                    /* Page number */
   int nRef;                       /* Number of outstanding references */
   int flags;                      /* Combination of PAGE_XXX flags */
   Page *pHashNext;                /* Next page in hash table slot */
@@ -332,7 +332,7 @@ static int IOERR_WRAPPER(int rc){
 #ifdef NDEBUG
 # define assert_lists_are_ok(x)
 #else
-static Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash);
+static Page *fsPageFindInHash(FileSystem *pFS, LsmPgno iPg, int *piHash);
 
 static void assert_lists_are_ok(FileSystem *pFS){
 #if 0
@@ -532,7 +532,7 @@ int lsmFsCloseAndDeleteLog(FileSystem *pFS){
 ** Return true if page iReal of the database should be accessed using mmap.
 ** False otherwise.
 */
-static int fsMmapPage(FileSystem *pFS, Pgno iReal){
+static int fsMmapPage(FileSystem *pFS, LsmPgno iReal){
   return ((i64)iReal*pFS->nPagesize <= pFS->nMapLimit);
 }
 
@@ -540,7 +540,7 @@ static int fsMmapPage(FileSystem *pFS, Pgno iReal){
 ** Given that there are currently nHash slots in the hash table, return 
 ** the hash key for file iFile, page iPg.
 */
-static int fsHashKey(int nHash, Pgno iPg){
+static int fsHashKey(int nHash, LsmPgno iPg){
   return (iPg % nHash);
 }
 
@@ -880,13 +880,13 @@ void lsmFsSetBlockSize(FileSystem *pFS, int nBlocksize){
 ** page on each block is the byte offset immediately following the 4-byte
 ** "previous block" pointer at the start of each block.
 */
-static Pgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
-  Pgno iPg;
+static LsmPgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
+  LsmPgno iPg;
   if( pFS->pCompress ){
     if( iBlock==1 ){
       iPg = pFS->nMetasize * 2 + 4;
     }else{
-      iPg = pFS->nBlocksize * (Pgno)(iBlock-1) + 4;
+      iPg = pFS->nBlocksize * (LsmPgno)(iBlock-1) + 4;
     }
   }else{
     const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
@@ -907,9 +907,9 @@ static Pgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
 ** page on each block is the byte offset of the byte immediately before 
 ** the 4-byte "next block" pointer at the end of each block.
 */
-static Pgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
+static LsmPgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
   if( pFS->pCompress ){
-    return pFS->nBlocksize * (Pgno)iBlock - 1 - 4;
+    return pFS->nBlocksize * (LsmPgno)iBlock - 1 - 4;
   }else{
     const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
     return iBlock * nPagePerBlock;
@@ -920,7 +920,7 @@ static Pgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
 ** Return the block number of the block that page iPg is located on. 
 ** Blocks are numbered starting from 1.
 */
-static int fsPageToBlock(FileSystem *pFS, Pgno iPg){
+static int fsPageToBlock(FileSystem *pFS, LsmPgno iPg){
   if( pFS->pCompress ){
     return (int)((iPg / pFS->nBlocksize) + 1);
   }else{
@@ -933,7 +933,7 @@ static int fsPageToBlock(FileSystem *pFS, Pgno iPg){
 **
 ** This function is only called in non-compressed database mode.
 */
-static int fsIsLast(FileSystem *pFS, Pgno iPg){
+static int fsIsLast(FileSystem *pFS, LsmPgno iPg){
   const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
   assert( !pFS->pCompress );
   return ( iPg && (iPg % nPagePerBlock)==0 );
@@ -944,7 +944,7 @@ static int fsIsLast(FileSystem *pFS, Pgno iPg){
 **
 ** This function is only called in non-compressed database mode.
 */
-static int fsIsFirst(FileSystem *pFS, Pgno iPg){
+static int fsIsFirst(FileSystem *pFS, LsmPgno iPg){
   const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
   assert( !pFS->pCompress );
   return ( (iPg % nPagePerBlock)==1
@@ -967,7 +967,7 @@ u8 *lsmFsPageData(Page *pPage, int *pnData){
 /*
 ** Return the page number of a page.
 */
-Pgno lsmFsPageNumber(Page *pPage){
+LsmPgno lsmFsPageNumber(Page *pPage){
   /* assert( (pPage->flags & PAGE_DIRTY)==0 ); */
   return pPage ? pPage->iPg : 0;
 }
@@ -1058,7 +1058,7 @@ void lsmFsPurgeCache(FileSystem *pFS){
 ** Either way, if argument piHash is not NULL set *piHash to the hash slot
 ** number that page iPg would be stored in before returning.
 */
-static Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash){
+static Page *fsPageFindInHash(FileSystem *pFS, LsmPgno iPg, int *piHash){
   Page *p;                        /* Return value */
   int iHash = fsHashKey(pFS->nHash, iPg);
 
@@ -1189,8 +1189,8 @@ static int fsRedirectBlock(Redirect *p, int iBlk){
 ** object passed as the second argument, return the destination page to
 ** which it is redirected. Otherwise, return a copy of iPg.
 */
-Pgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, Pgno iPg){
-  Pgno iReal = iPg;
+LsmPgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, LsmPgno iPg){
+  LsmPgno iReal = iPg;
 
   if( pRedir ){
     const int nPagePerBlock = (
@@ -1203,7 +1203,7 @@ Pgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, Pgno iPg){
       if( iFrom>iBlk ) break;
       if( iFrom==iBlk ){
         int iTo = pRedir->a[i].iTo;
-        iReal = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;
+        iReal = iPg - (LsmPgno)(iFrom - iTo) * nPagePerBlock;
         if( iTo==1 ){
           iReal += (fsFirstPageOnBlock(pFS, 1)-1);
         }
@@ -1217,7 +1217,7 @@ Pgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, Pgno iPg){
 }
 
 /* Required by the circular fsBlockNext<->fsPageGet dependency. */
-static int fsPageGet(FileSystem *, Segment *, Pgno, int, Page **, int *);
+static int fsPageGet(FileSystem *, Segment *, LsmPgno, int, Page **, int *);
 
 /*
 ** Parameter iBlock is a database file block. This function reads the value 
@@ -1269,7 +1269,7 @@ static int fsBlockNext(
 /*
 ** Return the page number of the last page on the same block as page iPg.
 */
-Pgno fsLastPageOnPagesBlock(FileSystem *pFS, Pgno iPg){
+LsmPgno fsLastPageOnPagesBlock(FileSystem *pFS, LsmPgno iPg){
   return fsLastPageOnBlock(pFS, fsPageToBlock(pFS, iPg));
 }
 
@@ -1537,7 +1537,7 @@ static int fsReadPagedata(
 static int fsPageGet(
   FileSystem *pFS,                /* File-system handle */
   Segment *pSeg,                  /* Block redirection to use (or NULL) */
-  Pgno iPg,                       /* Page id */
+  LsmPgno iPg,                    /* Page id */
   int noContent,                  /* True to not load content from disk */
   Page **ppPg,                    /* OUT: New page handle */
   int *pnSpace                    /* OUT: Bytes of free space */
@@ -1549,7 +1549,7 @@ static int fsPageGet(
   /* In most cases iReal is the same as iPg. Except, if pSeg->pRedirect is 
   ** not NULL, and the block containing iPg has been redirected, then iReal
   ** is the page number after redirection.  */
-  Pgno iReal = lsmFsRedirectPage(pFS, (pSeg ? pSeg->pRedirect : 0), iPg);
+  LsmPgno iReal = lsmFsRedirectPage(pFS, (pSeg ? pSeg->pRedirect : 0), iPg);
 
   assert_lists_are_ok(pFS);
   assert( iPg>=fsFirstPageOnBlock(pFS, 1) );
@@ -1689,8 +1689,8 @@ int lsmFsReadSyncedId(lsm_db *db, int iMeta, i64 *piVal){
 static int fsRunEndsBetween(
   Segment *pRun, 
   Segment *pIgnore, 
-  Pgno iFirst, 
-  Pgno iLast
+  LsmPgno iFirst, 
+  LsmPgno iLast
 ){
   return (pRun!=pIgnore && (
         (pRun->iFirst>=iFirst && pRun->iFirst<=iLast)
@@ -1705,8 +1705,8 @@ static int fsRunEndsBetween(
 static int fsLevelEndsBetween(
   Level *pLevel, 
   Segment *pIgnore, 
-  Pgno iFirst, 
-  Pgno iLast
+  LsmPgno iFirst, 
+  LsmPgno iLast
 ){
   int i;
 
@@ -1733,13 +1733,13 @@ static int fsFreeBlock(
   int iBlk                        /* Block number of block to free */
 ){
   int rc = LSM_OK;                /* Return code */
-  Pgno iFirst;                    /* First page on block iBlk */
-  Pgno iLast;                     /* Last page on block iBlk */
+  LsmPgno iFirst;                 /* First page on block iBlk */
+  LsmPgno iLast;                  /* Last page on block iBlk */
   Level *pLevel;                  /* Used to iterate through levels */
 
   int iIn;                        /* Used to iterate through append points */
   int iOut = 0;                   /* Used to output append points */
-  Pgno *aApp = pSnapshot->aiAppend;
+  LsmPgno *aApp = pSnapshot->aiAppend;
 
   iFirst = fsFirstPageOnBlock(pFS, iBlk);
   iLast = fsLastPageOnBlock(pFS, iBlk);
@@ -1811,11 +1811,16 @@ int lsmFsSortedDelete(
 ** number from the array that falls on block iBlk. Or, if none of the pages
 ** in aPgno[] fall on block iBlk, return 0.
 */
-static Pgno firstOnBlock(FileSystem *pFS, int iBlk, Pgno *aPgno, int nPgno){
-  Pgno iRet = 0;
+static LsmPgno firstOnBlock(
+  FileSystem *pFS, 
+  int iBlk, 
+  LsmPgno *aPgno, 
+  int nPgno
+){
+  LsmPgno iRet = 0;
   int i;
   for(i=0; i<nPgno; i++){
-    Pgno iPg = aPgno[i];
+    LsmPgno iPg = aPgno[i];
     if( fsPageToBlock(pFS, iPg)==iBlk && (iRet==0 || iPg<iRet) ){
       iRet = iPg;
     }
@@ -1828,7 +1833,7 @@ static Pgno firstOnBlock(FileSystem *pFS, int iBlk, Pgno *aPgno, int nPgno){
 ** Return true if page iPg, which is a part of segment p, lies on
 ** a redirected block. 
 */
-static int fsPageRedirects(FileSystem *pFS, Segment *p, Pgno iPg){
+static int fsPageRedirects(FileSystem *pFS, Segment *p, LsmPgno iPg){
   return (iPg!=0 && iPg!=lsmFsRedirectPage(pFS, p->pRedirect, iPg));
 }
 
@@ -1854,7 +1859,7 @@ static int fsSegmentRedirects(FileSystem *pFS, Segment *p){
 void lsmFsGobble(
   lsm_db *pDb,
   Segment *pRun, 
-  Pgno *aPgno,
+  LsmPgno *aPgno,
   int nPgno
 ){
   int rc = LSM_OK;
@@ -1871,7 +1876,7 @@ void lsmFsGobble(
 
   while( rc==LSM_OK ){
     int iNext = 0;
-    Pgno iFirst = firstOnBlock(pFS, iBlk, aPgno, nPgno);
+    LsmPgno iFirst = firstOnBlock(pFS, iBlk, aPgno, nPgno);
     if( iFirst ){
       pRun->iFirst = iFirst;
       break;
@@ -1905,11 +1910,11 @@ void lsmFsGobble(
 static int fsNextPageOffset(
   FileSystem *pFS,                /* File system object */
   Segment *pSeg,                  /* Segment to move within */
-  Pgno iPg,                       /* Offset of current page */
+  LsmPgno iPg,                    /* Offset of current page */
   int nByte,                      /* Size of current page including headers */
-  Pgno *piNext                    /* OUT: Offset of next page. Or zero (EOF) */
+  LsmPgno *piNext                 /* OUT: Offset of next page. Or zero (EOF) */
 ){
-  Pgno iNext;
+  LsmPgno iNext;
   int rc;
 
   assert( pFS->pCompress );
@@ -1939,8 +1944,8 @@ static int fsNextPageOffset(
 static int fsGetPageBefore(
   FileSystem *pFS, 
   Segment *pSeg, 
-  Pgno iPg, 
-  Pgno *piPrev
+  LsmPgno iPg, 
+  LsmPgno *piPrev
 ){
   u8 aSz[3];
   int rc;
@@ -1990,7 +1995,7 @@ static int fsGetPageBefore(
 int lsmFsDbPageNext(Segment *pRun, Page *pPg, int eDir, Page **ppNext){
   int rc = LSM_OK;
   FileSystem *pFS = pPg->pFS;
-  Pgno iPg = pPg->iPg;
+  LsmPgno iPg = pPg->iPg;
 
   assert( 0==fsSegmentRedirects(pFS, pRun) );
   if( pFS->pCompress ){
@@ -2062,10 +2067,10 @@ int lsmFsDbPageNext(Segment *pRun, Page *pPg, int eDir, Page **ppNext){
 ** start the new segment immediately following any segment that is part
 ** of the right-hand-side of pLvl.
 */
-static Pgno findAppendPoint(FileSystem *pFS, Level *pLvl){
+static LsmPgno findAppendPoint(FileSystem *pFS, Level *pLvl){
   int i;
-  Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;
-  Pgno iRet = 0;
+  LsmPgno *aiAppend = pFS->pDb->pWorker->aiAppend;
+  LsmPgno iRet = 0;
 
   for(i=LSM_APPLIST_SZ-1; iRet==0 && i>=0; i--){
     if( (iRet = aiAppend[i]) ){
@@ -2098,10 +2103,10 @@ int lsmFsSortedAppend(
 ){
   int rc = LSM_OK;
   Page *pPg = 0;
-  Pgno iApp = 0;
-  Pgno iNext = 0;
+  LsmPgno iApp = 0;
+  LsmPgno iNext = 0;
   Segment *p = &pLvl->lhs;
-  Pgno iPrev = p->iLastPg;
+  LsmPgno iPrev = p->iLastPg;
 
   *ppOut = 0;
   assert( p->pRedirect==0 );
@@ -2195,7 +2200,7 @@ int lsmFsSortedFinish(FileSystem *pFS, Segment *p){
     */
     if( fsLastPageOnPagesBlock(pFS, p->iLastPg)!=p->iLastPg ){
       int i;
-      Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;
+      LsmPgno *aiAppend = pFS->pDb->pWorker->aiAppend;
       for(i=0; i<LSM_APPLIST_SZ; i++){
         if( aiAppend[i]==0 ){
           aiAppend[i] = p->iLastPg+1;
@@ -2226,7 +2231,7 @@ int lsmFsSortedFinish(FileSystem *pFS, Segment *p){
 **
 ** Return LSM_OK if successful, or an lsm error code if an error occurs.
 */
-int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, Pgno iPg, Page **ppPg){
+int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, LsmPgno iPg, Page **ppPg){
   return fsPageGet(pFS, pSeg, iPg, 0, ppPg, 0);
 }
 
@@ -2238,7 +2243,7 @@ int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, Pgno iPg, Page **ppPg){
 */
 int lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg){
   int rc;
-  Pgno iPg = pSeg->iLastPg;
+  LsmPgno iPg = pSeg->iLastPg;
   if( pFS->pCompress ){
     int nSpace;
     iPg++;
@@ -2366,14 +2371,14 @@ static void fsMovePage(
   FileSystem *pFS,                /* File system object */
   int iTo,                        /* Destination block */
   int iFrom,                      /* Source block */
-  Pgno *piPg                      /* IN/OUT: Page number */
+  LsmPgno *piPg                   /* IN/OUT: Page number */
 ){
-  Pgno iPg = *piPg;
+  LsmPgno iPg = *piPg;
   if( iFrom==fsPageToBlock(pFS, iPg) ){
     const int nPagePerBlock = (
         pFS->pCompress ? pFS ->nBlocksize : (pFS->nBlocksize / pFS->nPagesize)
     );
-    *piPg = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;
+    *piPg = iPg - (LsmPgno)(iFrom - iTo) * nPagePerBlock;
   }
 }
 
@@ -2457,21 +2462,21 @@ int lsmFsMoveBlock(FileSystem *pFS, Segment *pSeg, int iTo, int iFrom){
 **
 ** This function is only used in compressed database mode.
 */
-static Pgno fsAppendData(
+static LsmPgno fsAppendData(
   FileSystem *pFS,                /* File-system handle */
   Segment *pSeg,                  /* Segment to append to */
   const u8 *aData,                /* Buffer containing data to write */
   int nData,                      /* Size of buffer aData[] in bytes */
   int *pRc                        /* IN/OUT: Error code */
 ){
-  Pgno iRet = 0;
+  LsmPgno iRet = 0;
   int rc = *pRc;
   assert( pFS->pCompress );
   if( rc==LSM_OK ){
     int nRem = 0;
     int nWrite = 0;
-    Pgno iLastOnBlock;
-    Pgno iApp = pSeg->iLastPg+1;
+    LsmPgno iLastOnBlock;
+    LsmPgno iApp = pSeg->iLastPg+1;
 
     /* If this is the first data written into the segment, find an append-point
     ** or allocate a new block.  */
@@ -2519,7 +2524,7 @@ static Pgno fsAppendData(
 
         /* Set the "prev" pointer on the new block */
         if( rc==LSM_OK ){
-          Pgno iWrite;
+          LsmPgno iWrite;
           lsmPutU32(aPtr, fsPageToBlock(pFS, iApp));
           iWrite = fsFirstPageOnBlock(pFS, iBlk);
           rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iWrite-4, aPtr, sizeof(aPtr));
@@ -2588,11 +2593,11 @@ static int fsCompressIntoBuffer(FileSystem *pFS, Page *pPg){
 static int fsAppendPage(
   FileSystem *pFS, 
   Segment *pSeg,
-  Pgno *piNew,
+  LsmPgno *piNew,
   int *piPrev,
   int *piNext
 ){
-  Pgno iPrev = pSeg->iLastPg;
+  LsmPgno iPrev = pSeg->iLastPg;
   int rc;
   assert( iPrev!=0 );
 
@@ -2650,7 +2655,7 @@ void lsmFsFlushWaiting(FileSystem *pFS, int *pRc){
 /*
 ** If there exists a hash-table entry associated with page iPg, remove it.
 */
-static void fsRemoveHashEntry(FileSystem *pFS, Pgno iPg){
+static void fsRemoveHashEntry(FileSystem *pFS, LsmPgno iPg){
   Page *p;
   int iHash = fsHashKey(pFS->nHash, iPg);
 
@@ -2804,8 +2809,8 @@ int lsmFsSortedPadding(
 ){
   int rc = LSM_OK;
   if( pFS->pCompress && pSeg->iFirst ){
-    Pgno iLast2;
-    Pgno iLast = pSeg->iLastPg;     /* Current last page of segment */
+    LsmPgno iLast2;
+    LsmPgno iLast = pSeg->iLastPg;  /* Current last page of segment */
     int nPad;                       /* Bytes of padding required */
     u8 aSz[3];
 
@@ -2935,7 +2940,7 @@ int lsmFsSectorSize(FileSystem *pFS){
 /*
 ** Helper function for lsmInfoArrayStructure().
 */
-static Segment *startsWith(Segment *pRun, Pgno iFirst){
+static Segment *startsWith(Segment *pRun, LsmPgno iFirst){
   return (iFirst==pRun->iFirst) ? pRun : 0;
 }
 
@@ -2943,7 +2948,7 @@ static Segment *startsWith(Segment *pRun, Pgno iFirst){
 ** Return the segment that starts with page iFirst, if any. If no such segment
 ** can be found, return NULL.
 */
-static Segment *findSegment(Snapshot *pWorker, Pgno iFirst){
+static Segment *findSegment(Snapshot *pWorker, LsmPgno iFirst){
   Level *pLvl;                    /* Used to iterate through db levels */
   Segment *pSeg = 0;              /* Pointer to segment to return */
 
@@ -2970,7 +2975,7 @@ static Segment *findSegment(Snapshot *pWorker, Pgno iFirst){
 int lsmInfoArrayStructure(
   lsm_db *pDb, 
   int bBlock,                     /* True for block numbers only */
-  Pgno iFirst,
+  LsmPgno iFirst,
   char **pzOut
 ){
   int rc = LSM_OK;
@@ -3035,7 +3040,7 @@ int lsmInfoArrayStructure(
 int lsmFsSegmentContainsPg(
   FileSystem *pFS, 
   Segment *pSeg, 
-  Pgno iPg, 
+  LsmPgno iPg, 
   int *pbRes
 ){
   Redirect *pRedir = pSeg->pRedirect;
@@ -3064,7 +3069,7 @@ int lsmFsSegmentContainsPg(
 **
 ** If an error occurs, *pzOut is set to NULL and an LSM error code returned.
 */
-int lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut){
+int lsmInfoArrayPages(lsm_db *pDb, LsmPgno iFirst, char **pzOut){
   int rc = LSM_OK;
   Snapshot *pWorker;              /* Worker snapshot */
   Segment *pSeg = 0;              /* Array to report on */
@@ -3297,7 +3302,7 @@ int lsmFsIntegrityCheck(lsm_db *pDb){
 */
 int lsmFsDbPageIsLast(Segment *pSeg, Page *pPg){
   if( pPg->pFS->pCompress ){
-    Pgno iNext = 0;
+    LsmPgno iNext = 0;
     int rc;
     rc = fsNextPageOffset(pPg->pFS, pSeg, pPg->iPg, pPg->nCompress+6, &iNext);
     return (rc!=LSM_OK || iNext==0);
index 8a324a3efecb63914a010b2ed5e28c2b8f8cbb24..539883c469076a9076fe6808b7714a539fc85018 100644 (file)
@@ -583,14 +583,14 @@ int lsm_info(lsm_db *pDb, int eParam, ...){
     }
 
     case LSM_INFO_ARRAY_STRUCTURE: {
-      Pgno pgno = va_arg(ap, Pgno);
+      LsmPgno pgno = va_arg(ap, LsmPgno);
       char **pzVal = va_arg(ap, char **);
       rc = lsmInfoArrayStructure(pDb, 0, pgno, pzVal);
       break;
     }
 
     case LSM_INFO_ARRAY_PAGES: {
-      Pgno pgno = va_arg(ap, Pgno);
+      LsmPgno pgno = va_arg(ap, LsmPgno);
       char **pzVal = va_arg(ap, char **);
       rc = lsmInfoArrayPages(pDb, pgno, pzVal);
       break;
@@ -598,7 +598,7 @@ int lsm_info(lsm_db *pDb, int eParam, ...){
 
     case LSM_INFO_PAGE_HEX_DUMP:
     case LSM_INFO_PAGE_ASCII_DUMP: {
-      Pgno pgno = va_arg(ap, Pgno);
+      LsmPgno pgno = va_arg(ap, LsmPgno);
       char **pzVal = va_arg(ap, char **);
       int bUnlock = 0;
       rc = infoGetWorker(pDb, 0, &bUnlock);
index 9eff2d08cc3d7e423a42719853aa3dd4056d8937..171d0ec05c15829d2d96eaca56af92c425e959db 100644 (file)
 #endif
 
 typedef struct SegmentPtr SegmentPtr;
-typedef struct Blob Blob;
+typedef struct LsmBlob LsmBlob;
 
-struct Blob {
+struct LsmBlob {
   lsm_env *pEnv;
   void *pData;
   int nData;
@@ -129,18 +129,18 @@ struct SegmentPtr {
   Page *pPg;                    /* Current page */
   u16 flags;                    /* Copy of page flags field */
   int nCell;                    /* Number of cells on pPg */
-  Pgno iPtr;                    /* Base cascade pointer */
+  LsmPgno iPtr;                 /* Base cascade pointer */
 
   /* Current cell. See segmentPtrLoadCell() */
   int iCell;                    /* Current record within page pPg */
   int eType;                    /* Type of current record */
-  Pgno iPgPtr;                  /* Cascade pointer offset */
+  LsmPgno iPgPtr;               /* Cascade pointer offset */
   void *pKey; int nKey;         /* Key associated with current record */
   void *pVal; int nVal;         /* Current record value (eType==WRITE only) */
 
   /* Blobs used to allocate buffers for pKey and pVal as required */
-  Blob blob1;
-  Blob blob2;
+  LsmBlob blob1;
+  LsmBlob blob2;
 };
 
 /*
@@ -171,10 +171,10 @@ struct BtreeCursor {
   void *pKey;
   int nKey;
   int eType;
-  Pgno iPtr;
+  LsmPgno iPtr;
 
   /* Storage for key, if not local */
-  Blob blob;
+  LsmBlob blob;
 };
 
 
@@ -203,8 +203,8 @@ struct MultiCursor {
   int flags;                      /* Mask of CURSOR_XXX flags */
 
   int eType;                      /* Cache of current key type */
-  Blob key;                       /* Cache of current key (or NULL) */
-  Blob val;                       /* Cache of current value */
+  LsmBlob key;                    /* Cache of current key (or NULL) */
+  LsmBlob val;                    /* Cache of current value */
 
   /* All the component cursors: */
   TreeCursor *apTreeCsr[2];       /* Up to two tree cursors */
@@ -221,7 +221,7 @@ struct MultiCursor {
   void *pSystemVal;               /* Pointer to buffer to free */
 
   /* Used by worker cursors only */
-  Pgno *pPrevMergePtr;
+  LsmPgno *pPrevMergePtr;
 };
 
 /*
@@ -295,11 +295,11 @@ struct MergeWorker {
   Hierarchy hier;                 /* B-tree hierarchy under construction */
   Page *pPage;                    /* Current output page */
   int nWork;                      /* Number of calls to mergeWorkerNextPage() */
-  Pgno *aGobble;                  /* Gobble point for each input segment */
+  LsmPgno *aGobble;               /* Gobble point for each input segment */
 
-  Pgno iIndirect;
+  LsmPgno iIndirect;
   struct SavedPgno {
-    Pgno iPgno;
+    LsmPgno iPgno;
     int bStore;
   } aSave[2];
 };
@@ -371,7 +371,7 @@ void lsmPutU64(u8 *aOut, u64 nVal){
   aOut[7] = (u8)((nVal    ) & 0xFF);
 }
 
-static int sortedBlobGrow(lsm_env *pEnv, Blob *pBlob, int nData){
+static int sortedBlobGrow(lsm_env *pEnv, LsmBlob *pBlob, int nData){
   assert( pBlob->pEnv==pEnv || (pBlob->pEnv==0 && pBlob->pData==0) );
   if( pBlob->nAlloc<nData ){
     pBlob->pData = lsmReallocOrFree(pEnv, pBlob->pData, nData);
@@ -382,7 +382,7 @@ static int sortedBlobGrow(lsm_env *pEnv, Blob *pBlob, int nData){
   return LSM_OK;
 }
 
-static int sortedBlobSet(lsm_env *pEnv, Blob *pBlob, void *pData, int nData){
+static int sortedBlobSet(lsm_env *pEnv, LsmBlob *pBlob, void *pData, int nData){
   if( sortedBlobGrow(pEnv, pBlob, nData) ) return LSM_NOMEM;
   memcpy(pBlob->pData, pData, nData);
   pBlob->nData = nData;
@@ -390,15 +390,15 @@ static int sortedBlobSet(lsm_env *pEnv, Blob *pBlob, void *pData, int nData){
 }
 
 #if 0
-static int sortedBlobCopy(Blob *pDest, Blob *pSrc){
+static int sortedBlobCopy(LsmBlob *pDest, LsmBlob *pSrc){
   return sortedBlobSet(pDest, pSrc->pData, pSrc->nData);
 }
 #endif
 
-static void sortedBlobFree(Blob *pBlob){
+static void sortedBlobFree(LsmBlob *pBlob){
   assert( pBlob->pEnv || pBlob->pData==0 );
   if( pBlob->pData ) lsmFree(pBlob->pEnv, pBlob->pData);
-  memset(pBlob, 0, sizeof(Blob));
+  memset(pBlob, 0, sizeof(LsmBlob));
 }
 
 static int sortedReadData(
@@ -407,7 +407,7 @@ static int sortedReadData(
   int iOff,
   int nByte,
   void **ppData,
-  Blob *pBlob
+  LsmBlob *pBlob
 ){
   int rc = LSM_OK;
   int iEnd;
@@ -481,8 +481,8 @@ static int pageGetNRec(u8 *aData, int nData){
   return (int)lsmGetU16(&aData[SEGMENT_NRECORD_OFFSET(nData)]);
 }
 
-static Pgno pageGetPtr(u8 *aData, int nData){
-  return (Pgno)lsmGetU64(&aData[SEGMENT_POINTER_OFFSET(nData)]);
+static LsmPgno pageGetPtr(u8 *aData, int nData){
+  return (LsmPgno)lsmGetU64(&aData[SEGMENT_POINTER_OFFSET(nData)]);
 }
 
 static int pageGetFlags(u8 *aData, int nData){
@@ -506,8 +506,8 @@ static int pageObjGetNRec(Page *pPg){
 ** Return the decoded (possibly relative) pointer value stored in cell 
 ** iCell from page aData/nData.
 */
-static Pgno pageGetRecordPtr(u8 *aData, int nData, int iCell){
-  Pgno iRet;                      /* Return value */
+static LsmPgno pageGetRecordPtr(u8 *aData, int nData, int iCell){
+  LsmPgno iRet;                   /* Return value */
   u8 *aCell;                      /* Pointer to cell iCell */
 
   assert( iCell<pageGetNRec(aData, nData) && iCell>=0 );
@@ -522,7 +522,7 @@ static u8 *pageGetKey(
   int iCell,                      /* Index of cell on page to read */
   int *piTopic,                   /* OUT: Topic associated with this key */
   int *pnKey,                     /* OUT: Size of key in bytes */
-  Blob *pBlob                     /* If required, use this for dynamic memory */
+  LsmBlob *pBlob                  /* If required, use this for dynamic memory */
 ){
   u8 *pKey;
   int nDummy;
@@ -554,7 +554,7 @@ static int pageGetKeyCopy(
   Page *pPg,                      /* Page to read from */
   int iCell,                      /* Index of cell on page to read */
   int *piTopic,                   /* OUT: Topic associated with this key */
-  Blob *pBlob                     /* If required, use this for dynamic memory */
+  LsmBlob *pBlob                  /* If required, use this for dynamic memory */
 ){
   int rc = LSM_OK;
   int nKey;
@@ -569,8 +569,8 @@ static int pageGetKeyCopy(
   return rc;
 }
 
-static Pgno pageGetBtreeRef(Page *pPg, int iKey){
-  Pgno iRef;
+static LsmPgno pageGetBtreeRef(Page *pPg, int iKey){
+  LsmPgno iRef;
   u8 *aData;
   int nData;
   u8 *aCell;
@@ -592,11 +592,11 @@ static int pageGetBtreeKey(
   Segment *pSeg,                  /* Segment page pPg belongs to */
   Page *pPg,
   int iKey, 
-  Pgno *piPtr, 
+  LsmPgno *piPtr, 
   int *piTopic, 
   void **ppKey,
   int *pnKey,
-  Blob *pBlob
+  LsmBlob *pBlob
 ){
   u8 *aData;
   int nData;
@@ -613,7 +613,7 @@ static int pageGetBtreeKey(
 
   if( eType==0 ){
     int rc;
-    Pgno iRef;                  /* Page number of referenced page */
+    LsmPgno iRef;               /* Page number of referenced page */
     Page *pRef;
     aCell += GETVARINT64(aCell, iRef);
     rc = lsmFsDbPageGet(lsmPageFS(pPg), pSeg, iRef, &pRef);
@@ -638,7 +638,7 @@ static int btreeCursorLoadKey(BtreeCursor *pCsr){
     pCsr->nKey = 0;
     pCsr->eType = 0;
   }else{
-    Pgno dummy;
+    LsmPgno dummy;
     int iPg = pCsr->iPg;
     int iCell = pCsr->aPg[iPg].iCell;
     while( iCell<0 && (--iPg)>=0 ){
@@ -683,7 +683,7 @@ static int btreeCursorNext(BtreeCursor *pCsr){
   assert( pPg->iCell<=nCell );
   pPg->iCell++;
   if( pPg->iCell==nCell ){
-    Pgno iLoad;
+    LsmPgno iLoad;
 
     /* Up to parent. */
     lsmFsPageRelease(pPg->pPage);
@@ -842,7 +842,7 @@ static int btreeCursorRestore(
   if( p->iPg ){
     lsm_env *pEnv = lsmFsEnv(pCsr->pFS);
     int iCell;                    /* Current cell number on leaf page */
-    Pgno iLeaf;                   /* Page number of current leaf page */
+    LsmPgno iLeaf;                /* Page number of current leaf page */
     int nDepth;                   /* Depth of b-tree structure */
     Segment *pSeg = pCsr->pSeg;
 
@@ -866,7 +866,7 @@ static int btreeCursorRestore(
 
     /* Populate any other aPg[] array entries */
     if( rc==LSM_OK && nDepth>1 ){
-      Blob blob = {0,0,0};
+      LsmBlob blob = {0,0,0};
       void *pSeek;
       int nSeek;
       int iTopicSeek;
@@ -883,7 +883,7 @@ static int btreeCursorRestore(
         pSeek = 0;
         nSeek = 0;
       }else{
-        Pgno dummy;
+        LsmPgno dummy;
         rc = pageGetBtreeKey(pSeg, pPg,
             0, &dummy, &iTopicSeek, &pSeek, &nSeek, &pCsr->blob
         );
@@ -912,7 +912,7 @@ static int btreeCursorRestore(
             int iTry = (iMin+iMax)/2;
             void *pKey; int nKey;         /* Key for cell iTry */
             int iTopic;                   /* Topic for key pKeyT/nKeyT */
-            Pgno iPtr;                    /* Pointer for cell iTry */
+            LsmPgno iPtr;                 /* Pointer for cell iTry */
             int res;                      /* (pSeek - pKeyT) */
 
             rc = pageGetBtreeKey(
@@ -955,7 +955,7 @@ static int btreeCursorRestore(
       aData = fsPageData(pBtreePg->pPage, &nData);
       pCsr->iPtr = btreeCursorPtr(aData, nData, pBtreePg->iCell+1);
       if( pBtreePg->iCell<0 ){
-        Pgno dummy;
+        LsmPgno dummy;
         int i;
         for(i=pCsr->iPg-1; i>=0; i--){
           if( pCsr->aPg[i].iCell>0 ) break;
@@ -1030,7 +1030,7 @@ static int segmentPtrReadData(
   int iOff,
   int nByte,
   void **ppData,
-  Blob *pBlob
+  LsmBlob *pBlob
 ){
   return sortedReadData(pPtr->pSeg, pPtr->pPg, iOff, nByte, ppData, pBlob);
 }
@@ -1123,7 +1123,7 @@ static void sortedSplitkey(lsm_db *pDb, Level *pLevel, int *pRc){
   }
   if( rc==LSM_OK ){
     int iTopic;
-    Blob blob = {0, 0, 0, 0};
+    LsmBlob blob = {0, 0, 0, 0};
     u8 *aData;
     int nData;
   
@@ -1131,7 +1131,7 @@ static void sortedSplitkey(lsm_db *pDb, Level *pLevel, int *pRc){
     if( pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG ){
       void *pKey;
       int nKey;
-      Pgno dummy;
+      LsmPgno dummy;
       rc = pageGetBtreeKey(pSeg,
           pPg, pMerge->splitkey.iCell, &dummy, &iTopic, &pKey, &nKey, &blob
       );
@@ -1342,7 +1342,7 @@ static int assertKeyLocation(
   void *pKey, int nKey
 ){
   lsm_env *pEnv = lsmFsEnv(pCsr->pDb->pFS);
-  Blob blob = {0, 0, 0};
+  LsmBlob blob = {0, 0, 0};
   int eDir;
   int iTopic = 0;                 /* TODO: Fix me */
 
@@ -1488,7 +1488,7 @@ static int ptrFwdPointer(
   Page *pPage,
   int iCell,
   Segment *pSeg,
-  Pgno *piPtr,
+  LsmPgno *piPtr,
   int *pbFound
 ){
   Page *pPg = pPage;
@@ -1573,14 +1573,14 @@ static int sortedRhsFirst(MultiCursor *pCsr, Level *pLvl, SegmentPtr *pPtr){
 static int segmentPtrFwdPointer(
   MultiCursor *pCsr,              /* Multi-cursor pPtr belongs to */
   SegmentPtr *pPtr,               /* Segment-pointer to extract FC ptr from */
-  Pgno *piPtr                     /* OUT: FC pointer value */
+  LsmPgno *piPtr                  /* OUT: FC pointer value */
 ){
   Level *pLvl = pPtr->pLevel;
   Level *pNext = pLvl->pNext;
   Page *pPg = pPtr->pPg;
   int rc;
   int bFound;
-  Pgno iOut = 0;
+  LsmPgno iOut = 0;
 
   if( pPtr->pSeg==&pLvl->lhs || pPtr->pSeg==&pLvl->aRhs[pLvl->nRight-1] ){
     if( pNext==0 
@@ -1641,7 +1641,7 @@ static int segmentPtrSeek(
   int rc = LSM_OK;
   int iMin;
   int iMax;
-  Pgno iPtrOut = 0;
+  LsmPgno iPtrOut = 0;
 
   /* If the current page contains an oversized entry, then there are no
   ** pointers to one or more of the subsequent pages in the sorted run.
@@ -1768,18 +1768,18 @@ static int seekInBtree(
   Segment *pSeg,                  /* Seek within this segment */
   int iTopic,
   void *pKey, int nKey,           /* Key to seek to */
-  Pgno *aPg,                      /* OUT: Page numbers */
+  LsmPgno *aPg,                   /* OUT: Page numbers */
   Page **ppPg                     /* OUT: Leaf (sorted-run) page reference */
 ){
   int i = 0;
   int rc;
   int iPg;
   Page *pPg = 0;
-  Blob blob = {0, 0, 0};
+  LsmBlob blob = {0, 0, 0};
 
   iPg = (int)pSeg->iRoot;
   do {
-    Pgno *piFirst = 0;
+    LsmPgno *piFirst = 0;
     if( aPg ){
       aPg[i++] = iPg;
       piFirst = &aPg[i];
@@ -1808,7 +1808,7 @@ static int seekInBtree(
         int iTry = (iMin+iMax)/2;
         void *pKeyT; int nKeyT;       /* Key for cell iTry */
         int iTopicT;                  /* Topic for key pKeyT/nKeyT */
-        Pgno iPtr;                    /* Pointer associated with cell iTry */
+        LsmPgno iPtr;                 /* Pointer associated with cell iTry */
         int res;                      /* (pKey - pKeyT) */
 
         rc = pageGetBtreeKey(
@@ -1899,7 +1899,7 @@ static int seekInLevel(
   int eSeek,                      /* Search bias - see above */
   int iTopic,                     /* Key topic to search for */
   void *pKey, int nKey,           /* Key to search for */
-  Pgno *piPgno,                   /* IN/OUT: fraction cascade pointer (or 0) */
+  LsmPgno *piPgno,                /* IN/OUT: fraction cascade pointer (or 0) */
   int *pbStop                     /* OUT: See above */
 ){
   Level *pLvl = aPtr[0].pLevel;   /* Level to seek within */
@@ -3055,7 +3055,7 @@ int lsmMCursorSeek(
   int bStop = 0;                  /* Set to true to halt search operation */
   int rc = LSM_OK;                /* Return code */
   int iPtr = 0;                   /* Used to iterate through pCsr->aPtr[] */
-  Pgno iPgno = 0;                 /* FC pointer value */
+  LsmPgno iPgno = 0;              /* FC pointer value */
 
   assert( pCsr->apTreeCsr[0]==0 || iTopic==0 );
   assert( pCsr->apTreeCsr[1]==0 || iTopic==0 );
@@ -3537,7 +3537,7 @@ static int mergeWorkerLoadHierarchy(MergeWorker *pMW){
 **         + Type byte (always SORTED_SEPARATOR or SORTED_SYSTEM_SEPARATOR),
 **         + Absolute pointer value (varint),
 **         + Number of bytes in key (varint),
-**         + Blob containing key data.
+**         + LsmBlob containing key data.
 **
 **   2. All pointer values are stored as absolute values (not offsets 
 **      relative to the footer pointer value).
@@ -3571,8 +3571,8 @@ static int mergeWorkerLoadHierarchy(MergeWorker *pMW){
 static int mergeWorkerBtreeWrite(
   MergeWorker *pMW,
   u8 eType,
-  Pgno iPtr,
-  Pgno iKeyPg,
+  LsmPgno iPtr,
+  LsmPgno iKeyPg,
   void *pKey,
   int nKey
 ){
@@ -3682,7 +3682,7 @@ static int mergeWorkerBtreeWrite(
 static int mergeWorkerBtreeIndirect(MergeWorker *pMW){
   int rc = LSM_OK;
   if( pMW->iIndirect ){
-    Pgno iKeyPg = pMW->aSave[1].iPgno;
+    LsmPgno iKeyPg = pMW->aSave[1].iPgno;
     rc = mergeWorkerBtreeWrite(pMW, 0, pMW->iIndirect, iKeyPg, 0, 0);
     pMW->iIndirect = 0;
   }
@@ -3703,7 +3703,7 @@ static int mergeWorkerPushHierarchy(
   int nKey                        /* Size of pKey buffer in bytes */
 ){
   int rc = LSM_OK;                /* Return Code */
-  Pgno iPtr;                      /* Pointer value to accompany pKey/nKey */
+  LsmPgno iPtr;                   /* Pointer value to accompany pKey/nKey */
 
   assert( pMW->aSave[0].bStore==0 );
   assert( pMW->aSave[1].bStore==0 );
@@ -3734,7 +3734,7 @@ static int mergeWorkerFinishHierarchy(
 ){
   int i;                          /* Used to loop through apHier[] */
   int rc = LSM_OK;                /* Return code */
-  Pgno iPtr;                      /* New right-hand-child pointer value */
+  LsmPgno iPtr;                   /* New right-hand-child pointer value */
 
   iPtr = pMW->aSave[0].iPgno;
   for(i=0; i<pMW->hier.nHier && rc==LSM_OK; i++){
@@ -3830,7 +3830,7 @@ static int mergeWorkerPersistAndRelease(MergeWorker *pMW){
 */
 static int mergeWorkerNextPage(
   MergeWorker *pMW,               /* Merge worker object to append page to */
-  Pgno iFPtr                      /* Pointer value for footer of new page */
+  LsmPgno iFPtr                   /* Pointer value for footer of new page */
 ){
   int rc = LSM_OK;                /* Return code */
   Page *pNext = 0;                /* New page appended to run */
@@ -4218,7 +4218,7 @@ static int mergeWorkerStep(MergeWorker *pMW){
   int rc = LSM_OK;              /* Return code */
   int eType;                    /* SORTED_SEPARATOR, WRITE or DELETE */
   void *pKey; int nKey;         /* Key */
-  Pgno iPtr;
+  LsmPgno iPtr;
   int iVal;
 
   pCsr = pMW->pCsr;
@@ -4371,7 +4371,7 @@ static int sortedNewToplevel(
   if( rc!=LSM_OK ){
     lsmMCursorClose(pCsr, 0);
   }else{
-    Pgno iLeftPtr = 0;
+    LsmPgno iLeftPtr = 0;
     Merge merge;                  /* Merge object used to create new level */
     MergeWorker mergeworker;      /* MergeWorker object for the same purpose */
 
@@ -4548,7 +4548,7 @@ static int mergeWorkerInit(
   memset(pMW, 0, sizeof(MergeWorker));
   pMW->pDb = pDb;
   pMW->pLevel = pLevel;
-  pMW->aGobble = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno) * pLevel->nRight, &rc);
+  pMW->aGobble = lsmMallocZeroRc(pDb->pEnv, sizeof(LsmPgno)*pLevel->nRight,&rc);
 
   /* Create a multi-cursor to read the data to write to the new
   ** segment. The new segment contains:
@@ -4630,7 +4630,7 @@ static int sortedBtreeGobble(
   int rc = LSM_OK;
   if( rtTopic(pCsr->eType)==0 ){
     Segment *pSeg = pCsr->aPtr[iGobble].pSeg;
-    Pgno *aPg;
+    LsmPgno *aPg;
     int nPg;
 
     /* Seek from the root of the b-tree to the segment leaf that may contain
@@ -4639,7 +4639,7 @@ static int sortedBtreeGobble(
     ** gobbled up to (but not including) the first of these page numbers.
     */
     assert( pSeg->iRoot>0 );
-    aPg = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno)*32, &rc);
+    aPg = lsmMallocZeroRc(pDb->pEnv, sizeof(LsmPgno)*32, &rc);
     if( rc==LSM_OK ){
       rc = seekInBtree(pCsr, pSeg, 
           rtTopic(pCsr->eType), pCsr->key.pData, pCsr->key.nData, aPg, 0
@@ -5466,9 +5466,9 @@ int lsmFlushTreeToDisk(lsm_db *pDb){
 */
 static char *segToString(lsm_env *pEnv, Segment *pSeg, int nMin){
   int nSize = pSeg->nSize;
-  Pgno iRoot = pSeg->iRoot;
-  Pgno iFirst = pSeg->iFirst;
-  Pgno iLast = pSeg->iLastPg;
+  LsmPgno iRoot = pSeg->iRoot;
+  LsmPgno iFirst = pSeg->iFirst;
+  LsmPgno iLast = pSeg->iLastPg;
   char *z;
 
   char *z1;
@@ -5527,7 +5527,7 @@ static int fileToString(
 }
 
 void sortedDumpPage(lsm_db *pDb, Segment *pRun, Page *pPg, int bVals){
-  Blob blob = {0, 0, 0};         /* Blob used for keys */
+  LsmBlob blob = {0, 0, 0};       /* LsmBlob used for keys */
   LsmString s;
   int i;
 
@@ -5563,7 +5563,7 @@ void sortedDumpPage(lsm_db *pDb, Segment *pRun, Page *pPg, int bVals){
     aCell += lsmVarintGet32(aCell, &iPgPtr);
 
     if( eType==0 ){
-      Pgno iRef;                  /* Page number of referenced page */
+      LsmPgno iRef;               /* Page number of referenced page */
       aCell += lsmVarintGet64(aCell, &iRef);
       lsmFsDbPageGet(pDb->pFS, pRun, iRef, &pRef);
       aKey = pageGetKey(pRun, pRef, 0, &iTopic, &nKey, &blob);
@@ -5607,7 +5607,7 @@ static void infoCellDump(
   int *piPgPtr,
   u8 **paKey, int *pnKey,
   u8 **paVal, int *pnVal,
-  Blob *pBlob
+  LsmBlob *pBlob
 ){
   u8 *aData; int nData;           /* Page data */
   u8 *aKey; int nKey = 0;         /* Key */
@@ -5625,7 +5625,7 @@ static void infoCellDump(
 
   if( eType==0 ){
     int dummy;
-    Pgno iRef;                  /* Page number of referenced page */
+    LsmPgno iRef;                 /* Page number of referenced page */
     aCell += lsmVarintGet64(aCell, &iRef);
     if( bIndirect ){
       lsmFsDbPageGet(pDb->pFS, pSeg, iRef, &pRef);
@@ -5671,7 +5671,7 @@ static int infoAppendBlob(LsmString *pStr, int bHex, u8 *z, int n){
 
 static int infoPageDump(
   lsm_db *pDb,                    /* Database handle */
-  Pgno iPg,                       /* Page number of page to dump */
+  LsmPgno iPg,                    /* Page number of page to dump */
   int flags,
   char **pzOut                    /* OUT: lsmMalloc'd string */
 ){
@@ -5712,7 +5712,7 @@ static int infoPageDump(
   }
 
   if( rc==LSM_OK ){
-    Blob blob = {0, 0, 0, 0};
+    LsmBlob blob = {0, 0, 0, 0};
     int nKeyWidth = 0;
     LsmString str;
     int nRec;
@@ -5747,7 +5747,7 @@ static int infoPageDump(
       u8 *aVal; int nVal = 0;       /* Value */
       int iPgPtr;
       int eType;
-      Pgno iAbsPtr;
+      LsmPgno iAbsPtr;
       char zFlags[8];
 
       infoCellDump(pDb, pSeg, bIndirect, pPg, iCell, &eType, &iPgPtr,
@@ -5813,7 +5813,7 @@ static int infoPageDump(
 
 int lsmInfoPageDump(
   lsm_db *pDb,                    /* Database handle */
-  Pgno iPg,                       /* Page number of page to dump */
+  LsmPgno iPg,                    /* Page number of page to dump */
   int bHex,                       /* True to output key/value in hex form */
   char **pzOut                    /* OUT: lsmMalloc'd string */
 ){
@@ -5989,8 +5989,8 @@ void lsmSortedExpandBtreePage(Page *pPg, int nOrig){
 #ifdef LSM_DEBUG_EXPENSIVE
 static void assertRunInOrder(lsm_db *pDb, Segment *pSeg){
   Page *pPg = 0;
-  Blob blob1 = {0, 0, 0, 0};
-  Blob blob2 = {0, 0, 0, 0};
+  LsmBlob blob1 = {0, 0, 0, 0};
+  LsmBlob blob2 = {0, 0, 0, 0};
 
   lsmFsDbPageGet(pDb->pFS, pSeg, pSeg->iFirst, &pPg);
   while( pPg ){
@@ -6052,7 +6052,7 @@ static int assertPointersOk(
   int rc = LSM_OK;                /* Error code */
   SegmentPtr ptr1;                /* Iterates through pOne */
   SegmentPtr ptr2;                /* Iterates through pTwo */
-  Pgno iPrev;
+  LsmPgno iPrev;
 
   assert( pOne && pTwo );
 
@@ -6075,7 +6075,7 @@ static int assertPointersOk(
   }
       
   while( rc==LSM_OK && ptr2.pPg ){
-    Pgno iThis;
+    LsmPgno iThis;
 
     /* Advance to the next page of segment pTwo that contains at least
     ** one cell. Break out of the loop if the iterator reaches EOF.  */
@@ -6137,7 +6137,7 @@ static int assertBtreeOk(
 ){
   int rc = LSM_OK;                /* Return code */
   if( pSeg->iRoot ){
-    Blob blob = {0, 0, 0};        /* Buffer used to cache overflow keys */
+    LsmBlob blob = {0, 0, 0};     /* Buffer used to cache overflow keys */
     FileSystem *pFS = pDb->pFS;   /* File system to read from */
     Page *pPg = 0;                /* Main run page */
     BtreeCursor *pCsr = 0;        /* Btree cursor */
index cad9609c6b85bdcc30c947063c4b3f015a0be3ec..f66d23cb12c67ff11a8c0ae9f2859521a4d57d30 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sscript\sto\samalgamate\sall\sLSM\sfiles\sinto\s"lsm1.c".
-D 2017-12-13T14:22:48.449
+C Change\ssome\sLSM\scode\sinternal\stypenames\sfrom\s"Blob"\sand\s"Pgno"\sto\s"LsmBlob"\nand\s"LsmPgno".\sThis\sallows\sthe\sLSM\scode\sto\sbe\scompiled\sas\sa\ssingle\sunit\swith\nsqlite3.c.
+D 2017-12-13T15:32:33.291
 F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc e5d7606238f55816da99f719969598df5b091aa2e9a6935c9412fcae8f53fc44
@@ -239,15 +239,15 @@ F ext/lsm1/lsm-test/lsmtest_tdb4.c 47e8bb5eba266472d690fb8264f1855ebdba0ae5a0e54
 F ext/lsm1/lsm-test/lsmtest_util.c 241622db5a332a09c8e6e7606b617d288a37b557f7d3bce0bb97809f67cc2806
 F ext/lsm1/lsm-test/lsmtest_win32.c 0e0a224674c4d3170631c41b026b56c7e1672b151f5261e1b4cc19068641da2d
 F ext/lsm1/lsm.h 0f6f64ff071471cb87bf98beb8386566f30ea001
-F ext/lsm1/lsmInt.h e9e5c5f08e35a104086102b3def94ee69cbc0d39002f6596f5c80a640439628e
-F ext/lsm1/lsm_ckpt.c ac6fb4581983291c2e0be6fbb68f12b26f0c08d606835c05417be1323d0fdd03
-F ext/lsm1/lsm_file.c 4b3fb56336fbc9d941e1b2042e809d986feebdc41e73dc7fc4fdc0dd1bd4274d
+F ext/lsm1/lsmInt.h 5983690e05e83653cc01ba9d8fbf8455e534ddf8349ed9adedbf46a7549760b0
+F ext/lsm1/lsm_ckpt.c 0eabfaf812ddb4ea43add38f05e430694cd054eb622c3e35af4c43118a2d5321
+F ext/lsm1/lsm_file.c 3c51841d5b3e7da162693cbac9a9f47eeedf6bcbbe2969a4d25e30c428c9fe36
 F ext/lsm1/lsm_log.c a8bf334532109bba05b09a504ee45fc393828b0d034ca61ab45e3940709d9a7c
-F ext/lsm1/lsm_main.c 15e73ccdafdd44ddeefc29e332079d88ba8f00c12c797b3c2b63d3171b5afce8
+F ext/lsm1/lsm_main.c 801295038b548ae2e5fae93f08c3f945154f40848a03ff26b16eab5d04ba573a
 F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a
 F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea
 F ext/lsm1/lsm_shared.c 76adfc1ed9ffebaf92746dde4b370ccc48143ca8b05b563816eadd2aadf1c525
-F ext/lsm1/lsm_sorted.c 8f899fb64a4c736ff3c27d5126c7ce181129ddffde947fe5fb657a7a413f470b
+F ext/lsm1/lsm_sorted.c d07ff7c28758542b8b4da4b5a1fb67b22a4d33e50e7f684cffe1f6c45cf5182c
 F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678bca82
 F ext/lsm1/lsm_tree.c 682679d7ef2b8b6f2fe77aeb532c8d29695bca671c220b0abac77069de5fb9fb
 F ext/lsm1/lsm_unix.c 57361bcf5b1a1a028f5d66571ee490e9064d2cfb145a2cc9e5ddade467bb551b
@@ -1680,7 +1680,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 9cede8a83ca4cd88d504050115e1e89e7b3d3cd3cb2ffb5b8961e311a23ff5e2
-R 0bb1b86efd302c3523a2137056206a8a
+P e32b69d73062e233b0ac853611d10b24546a346a603289ab0e339a3604ae2af4
+R 3d8a0d79c82564334f201ac883edd045
 U dan
-Z 0df44b61ec124ac51afd1eb16b579be7
+Z 7a59c9677684f4709aed2e3a45c7d151
index f9c2f8f2b4476e44fb2e1d8a252d497d692e0a23..d947d934df18cce8e323bfd272934422a92c3d3a 100644 (file)
@@ -1 +1 @@
-e32b69d73062e233b0ac853611d10b24546a346a603289ab0e339a3604ae2af4
\ No newline at end of file
+30bf38d589adf0b2eb613e184ffb03ed7e625736cb04fd5c341328f72bc5ef4d
\ No newline at end of file