亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? btree.c

?? Trolltech公司發布的基于C++圖形開發環境
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*** 2001 September 15**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.***************************************************************************** $Id: qt/btree.c   3.3.4   edited Mar 30 2004 $**** This file implements a external (disk-based) database using BTrees.** For a detailed discussion of BTrees, refer to****     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:**     "Sorting And Searching", pages 473-480. Addison-Wesley**     Publishing Company, Reading, Massachusetts.**** The basic idea is that each page of the file contains N database** entries and N+1 pointers to subpages.****   ----------------------------------------------------------------**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N) | Ptr(N+1) |**   ----------------------------------------------------------------**** All of the keys on the page that Ptr(0) points to have values less** than Key(0).  All of the keys on page Ptr(1) and its subpages have** values greater than Key(0) and less than Key(1).  All of the keys** on Ptr(N+1) and its subpages have values greater than Key(N).  And** so forth.**** Finding a particular key requires reading O(log(M)) pages from the ** disk where M is the number of entries in the tree.**** In this implementation, a single file can hold one or more separate ** BTrees.  Each BTree is identified by the index of its root page.  The** key and data for any entry are combined to form the "payload".  Up to** MX_LOCAL_PAYLOAD bytes of payload can be carried directly on the** database page.  If the payload is larger than MX_LOCAL_PAYLOAD bytes** then surplus bytes are stored on overflow pages.  The payload for an** entry and the preceding pointer are combined to form a "Cell".  Each ** page has a small header which contains the Ptr(N+1) pointer.**** The first page of the file contains a magic string used to verify that** the file really is a valid BTree database, a pointer to a list of unused** pages in the file, and some meta information.  The root of the first** BTree begins on page 2 of the file.  (Pages are numbered beginning with** 1, not 0.)  Thus a minimum database contains 2 pages.*/#include "sqliteInt.h"#include "pager.h"#include "btree.h"#include <assert.h>/* Forward declarations */static BtOps sqliteBtreeOps;static BtCursorOps sqliteBtreeCursorOps;/*** Macros used for byteswapping.  B is a pointer to the Btree** structure.  This is needed to access the Btree.needSwab boolean** in order to tell if byte swapping is needed or not.** X is an unsigned integer.  SWAB16 byte swaps a 16-bit integer.** SWAB32 byteswaps a 32-bit integer.*/#define SWAB16(B,X)   ((B)->needSwab? swab16((u16)X) : ((u16)X))#define SWAB32(B,X)   ((B)->needSwab? swab32(X) : (X))#define SWAB_ADD(B,X,A) \   if((B)->needSwab){ X=swab32(swab32(X)+A); }else{ X += (A); }/*** The following global variable - available only if SQLITE_TEST is** defined - is used to determine whether new databases are created in** native byte order or in non-native byte order.  Non-native byte order** databases are created for testing purposes only.  Under normal operation,** only native byte-order databases should be created, but we should be** able to read or write existing databases regardless of the byteorder.*/#ifdef SQLITE_TESTint btree_native_byte_order = 1;#else# define btree_native_byte_order 1#endif/*** Forward declarations of structures used only in this file.*/typedef struct PageOne PageOne;typedef struct MemPage MemPage;typedef struct PageHdr PageHdr;typedef struct Cell Cell;typedef struct CellHdr CellHdr;typedef struct FreeBlk FreeBlk;typedef struct OverflowPage OverflowPage;typedef struct FreelistInfo FreelistInfo;/*** All structures on a database page are aligned to 4-byte boundries.** This routine rounds up a number of bytes to the next multiple of 4.**** This might need to change for computer architectures that require** and 8-byte alignment boundry for structures.*/#define ROUNDUP(X)  ((X+3) & ~3)/*** This is a magic string that appears at the beginning of every** SQLite database in order to identify the file as a real database.*/static const char zMagicHeader[] =    "** This file contains an SQLite 2.1 database **";#define MAGIC_SIZE (sizeof(zMagicHeader))/*** This is a magic integer also used to test the integrity of the database** file.  This integer is used in addition to the string above so that** if the file is written on a little-endian architecture and read** on a big-endian architectures (or vice versa) we can detect the** problem.**** The number used was obtained at random and has no special** significance other than the fact that it represents a different** integer on little-endian and big-endian machines.*/#define MAGIC 0xdae37528/*** The first page of the database file contains a magic header string** to identify the file as an SQLite database file.  It also contains** a pointer to the first free page of the file.  Page 2 contains the** root of the principle BTree.  The file might contain other BTrees** rooted on pages above 2.**** The first page also contains SQLITE_N_BTREE_META integers that** can be used by higher-level routines.**** Remember that pages are numbered beginning with 1.  (See pager.c** for additional information.)  Page 0 does not exist and a page** number of 0 is used to mean "no such page".*/struct PageOne {  char zMagic[MAGIC_SIZE]; /* String that identifies the file as a database */  int iMagic;              /* Integer to verify correct byte order */  Pgno freeList;           /* First free page in a list of all free pages */  int nFree;               /* Number of pages on the free list */  int aMeta[SQLITE_N_BTREE_META-1];  /* User defined integers */};/*** Each database page has a header that is an instance of this** structure.**** PageHdr.firstFree is 0 if there is no free space on this page.** Otherwise, PageHdr.firstFree is the index in MemPage.u.aDisk[] of a ** FreeBlk structure that describes the first block of free space.  ** All free space is defined by a linked list of FreeBlk structures.**** Data is stored in a linked list of Cell structures.  PageHdr.firstCell** is the index into MemPage.u.aDisk[] of the first cell on the page.  The** Cells are kept in sorted order.**** A Cell contains all information about a database entry and a pointer** to a child page that contains other entries less than itself.  In** other words, the i-th Cell contains both Ptr(i) and Key(i).  The** right-most pointer of the page is contained in PageHdr.rightChild.*/struct PageHdr {  Pgno rightChild;  /* Child page that comes after all cells on this page */  u16 firstCell;    /* Index in MemPage.u.aDisk[] of the first cell */  u16 firstFree;    /* Index in MemPage.u.aDisk[] of the first free block */};/*** Entries on a page of the database are called "Cells".  Each Cell** has a header and data.  This structure defines the header.  The** key and data (collectively the "payload") follow this header on** the database page.**** A definition of the complete Cell structure is given below.  The** header for the cell must be defined first in order to do some** of the sizing #defines that follow.*/struct CellHdr {  Pgno leftChild; /* Child page that comes before this cell */  u16 nKey;       /* Number of bytes in the key */  u16 iNext;      /* Index in MemPage.u.aDisk[] of next cell in sorted order */  u8 nKeyHi;      /* Upper 8 bits of key size for keys larger than 64K bytes */  u8 nDataHi;     /* Upper 8 bits of data size when the size is more than 64K */  u16 nData;      /* Number of bytes of data */};/*** The key and data size are split into a lower 16-bit segment and an** upper 8-bit segment in order to pack them together into a smaller** space.  The following macros reassembly a key or data size back** into an integer.*/#define NKEY(b,h)  (SWAB16(b,h.nKey) + h.nKeyHi*65536)#define NDATA(b,h) (SWAB16(b,h.nData) + h.nDataHi*65536)/*** The minimum size of a complete Cell.  The Cell must contain a header** and at least 4 bytes of payload.*/#define MIN_CELL_SIZE  (sizeof(CellHdr)+4)/*** The maximum number of database entries that can be held in a single** page of the database. */#define MX_CELL ((SQLITE_USABLE_SIZE-sizeof(PageHdr))/MIN_CELL_SIZE)/*** The amount of usable space on a single page of the BTree.  This is the** page size minus the overhead of the page header.*/#define USABLE_SPACE  (SQLITE_USABLE_SIZE - sizeof(PageHdr))/*** The maximum amount of payload (in bytes) that can be stored locally for** a database entry.  If the entry contains more data than this, the** extra goes onto overflow pages.**** This number is chosen so that at least 4 cells will fit on every page.*/#define MX_LOCAL_PAYLOAD ((USABLE_SPACE/4-(sizeof(CellHdr)+sizeof(Pgno)))&~3)/*** Data on a database page is stored as a linked list of Cell structures.** Both the key and the data are stored in aPayload[].  The key always comes** first.  The aPayload[] field grows as necessary to hold the key and data,** up to a maximum of MX_LOCAL_PAYLOAD bytes.  If the size of the key and** data combined exceeds MX_LOCAL_PAYLOAD bytes, then Cell.ovfl is the** page number of the first overflow page.**** Though this structure is fixed in size, the Cell on the database** page varies in size.  Every cell has a CellHdr and at least 4 bytes** of payload space.  Additional payload bytes (up to the maximum of** MX_LOCAL_PAYLOAD) and the Cell.ovfl value are allocated only as** needed.*/struct Cell {  CellHdr h;                        /* The cell header */  char aPayload[MX_LOCAL_PAYLOAD];  /* Key and data */  Pgno ovfl;                        /* The first overflow page */};/*** Free space on a page is remembered using a linked list of the FreeBlk** structures.  Space on a database page is allocated in increments of** at least 4 bytes and is always aligned to a 4-byte boundry.  The** linked list of FreeBlks is always kept in order by address.*/struct FreeBlk {  u16 iSize;      /* Number of bytes in this block of free space */  u16 iNext;      /* Index in MemPage.u.aDisk[] of the next free block */};/*** The number of bytes of payload that will fit on a single overflow page.*/#define OVERFLOW_SIZE (SQLITE_USABLE_SIZE-sizeof(Pgno))/*** When the key and data for a single entry in the BTree will not fit in** the MX_LOCAL_PAYLOAD bytes of space available on the database page,** then all extra bytes are written to a linked list of overflow pages.** Each overflow page is an instance of the following structure.**** Unused pages in the database are also represented by instances of** the OverflowPage structure.  The PageOne.freeList field is the** page number of the first page in a linked list of unused database** pages.*/struct OverflowPage {  Pgno iNext;  char aPayload[OVERFLOW_SIZE];};/*** The PageOne.freeList field points to a linked list of overflow pages** hold information about free pages.  The aPayload section of each** overflow page contains an instance of the following structure.  The** aFree[] array holds the page number of nFree unused pages in the disk** file.*/struct FreelistInfo {  int nFree;  Pgno aFree[(OVERFLOW_SIZE-sizeof(int))/sizeof(Pgno)];};/*** For every page in the database file, an instance of the following structure** is stored in memory.  The u.aDisk[] array contains the raw bits read from** the disk.  The rest is auxiliary information held in memory only. The** auxiliary info is only valid for regular database pages - it is not** used for overflow pages and pages on the freelist.**** Of particular interest in the auxiliary info is the apCell[] entry.  Each** apCell[] entry is a pointer to a Cell structure in u.aDisk[].  The cells are** put in this array so that they can be accessed in constant time, rather** than in linear time which would be needed if we had to walk the linked ** list on every access.**** Note that apCell[] contains enough space to hold up to two more Cells** than can possibly fit on one page.  In the steady state, every apCell[]** points to memory inside u.aDisk[].  But in the middle of an insert** operation, some apCell[] entries may temporarily point to data space** outside of u.aDisk[].  This is a transient situation that is quickly** resolved.  But while it is happening, it is possible for a database** page to hold as many as two more cells than it might otherwise hold.** The extra two entries in apCell[] are an allowance for this situation.**** The pParent field points back to the parent page.  This allows us to** walk up the BTree from any leaf to the root.  Care must be taken to** unref() the parent page pointer when this page is no longer referenced.** The pageDestructor() routine handles that chore.*/struct MemPage {  union u_page_data {    char aDisk[SQLITE_PAGE_SIZE];  /* Page data stored on disk */    PageHdr hdr;                   /* Overlay page header */  } u;  u8 isInit;                     /* True if auxiliary data is initialized */  u8 idxShift;                   /* True if apCell[] indices have changed */  u8 isOverfull;                 /* Some apCell[] points outside u.aDisk[] */  MemPage *pParent;              /* The parent of this page.  NULL for root */  int idxParent;                 /* Index in pParent->apCell[] of this node */  int nFree;                     /* Number of free bytes in u.aDisk[] */  int nCell;                     /* Number of entries on this page */  Cell *apCell[MX_CELL+2];       /* All data entires in sorted order */};/*** The in-memory image of a disk page has the auxiliary information appended** to the end.  EXTRA_SIZE is the number of bytes of space needed to hold** that extra information.*/#define EXTRA_SIZE (sizeof(MemPage)-sizeof(union u_page_data))/*** Everything we need to know about an open database*/struct Btree {  BtOps *pOps;          /* Function table */  Pager *pPager;        /* The page cache */  BtCursor *pCursor;    /* A list of all open cursors */  PageOne *page1;       /* First page of the database */  u8 inTrans;           /* True if a transaction is in progress */  u8 inCkpt;            /* True if there is a checkpoint on the transaction */  u8 readOnly;          /* True if the underlying file is readonly */  u8 needSwab;          /* Need to byte-swapping */};typedef Btree Bt;/*** A cursor is a pointer to a particular entry in the BTree.** The entry is identified by its MemPage and the index in** MemPage.apCell[] of the entry.*/struct BtCursor {  BtCursorOps *pOps;        /* Function table */  Btree *pBt;               /* The Btree to which this cursor belongs */  BtCursor *pNext, *pPrev;  /* Forms a linked list of all cursors */  BtCursor *pShared;        /* Loop of cursors with the same root page */  Pgno pgnoRoot;            /* The root page of this tree */  MemPage *pPage;           /* Page that contains the entry */  int idx;                  /* Index of the entry in pPage->apCell[] */  u8 wrFlag;                /* True if writable */  u8 eSkip;                 /* Determines if next step operation is a no-op */  u8 iMatch;                /* compare result from last sqliteBtreeMoveto() */};/*** Legal values for BtCursor.eSkip.*/#define SKIP_NONE     0   /* Always step the cursor */#define SKIP_NEXT     1   /* The next sqliteBtreeNext() is a no-op */#define SKIP_PREV     2   /* The next sqliteBtreePrevious() is a no-op */#define SKIP_INVALID  3   /* Calls to Next() and Previous() are invalid *//* Forward declarations */static int fileBtreeCloseCursor(BtCursor *pCur);/*** Routines for byte swapping.*/u16 swab16(u16 x){  return ((x & 0xff)<<8) | ((x>>8)&0xff);}u32 swab32(u32 x){  return ((x & 0xff)<<24) | ((x & 0xff00)<<8) |         ((x>>8) & 0xff00) | ((x>>24)&0xff);}/*** Compute the total number of bytes that a Cell needs on the main** database page.  The number returned includes the Cell header,** local payload storage, and the pointer to overflow pages (if** applicable).  Additional space allocated on overflow pages** is NOT included in the value returned from this routine.*/static int cellSize(Btree *pBt, Cell *pCell){  int n = NKEY(pBt, pCell->h) + NDATA(pBt, pCell->h);  if( n>MX_LOCAL_PAYLOAD ){    n = MX_LOCAL_PAYLOAD + sizeof(Pgno);  }else{    n = ROUNDUP(n);  }  n += sizeof(CellHdr);  return n;}/*** Defragment the page given.  All Cells are moved to the

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区中文字幕电影| av一区二区久久| 成人白浆超碰人人人人| 欧美久久一二区| 中文字幕亚洲综合久久菠萝蜜| 亚洲国产欧美在线人成| 成人中文字幕合集| 欧美一区二区三区精品| 亚洲一卡二卡三卡四卡五卡| 成人亚洲一区二区一| 精品电影一区二区| 日韩黄色免费电影| 欧美色图天堂网| 亚洲欧美日韩国产手机在线| 国产91露脸合集magnet| 欧美精品一区二区三区久久久| 天天色综合天天| 欧美天堂一区二区三区| 亚洲精品中文在线影院| 成人av免费观看| 亚洲国产精品ⅴa在线观看| 韩国视频一区二区| 日韩午夜在线观看视频| 日韩经典一区二区| 欧美日韩精品欧美日韩精品一综合| 日韩美女视频一区| eeuss鲁片一区二区三区在线看| 久久精子c满五个校花| 国产综合色精品一区二区三区| 日韩丝袜美女视频| 蜜乳av一区二区| 日韩欧美亚洲国产另类| 久久er99精品| www久久精品| 国产高清在线观看免费不卡| 久久久久久久久久久电影| 国产伦精品一区二区三区在线观看| 欧美精品一区二区三区高清aⅴ | 日韩成人av影视| 欧美日韩国产经典色站一区二区三区| 亚洲精品国产精华液| 欧美三级视频在线播放| 五月婷婷激情综合| 日韩精品中文字幕一区| 国产在线麻豆精品观看| 国产丝袜美腿一区二区三区| 成人av免费在线| 亚洲第一av色| 欧美va亚洲va国产综合| 成人精品一区二区三区中文字幕| 国产精品久久久久久久久动漫 | www.性欧美| 亚洲一级二级在线| 日韩免费看网站| 国产·精品毛片| 亚洲伊人伊色伊影伊综合网| 欧美一区二区视频在线观看2020 | 亚洲成人免费在线观看| 欧美成人vps| 99久久99久久久精品齐齐| 亚洲一区二区三区免费视频| 欧美一级专区免费大片| 成人午夜精品在线| 亚洲一区二区不卡免费| 久久伊人蜜桃av一区二区| 91网站最新地址| 日本91福利区| 中文字幕五月欧美| 日韩一区二区三区在线视频| 国产v综合v亚洲欧| 亚洲国产日韩av| 国产日本欧洲亚洲| 日韩一区二区免费电影| eeuss鲁片一区二区三区| 日本亚洲三级在线| 成人欧美一区二区三区黑人麻豆 | 在线欧美小视频| 黄一区二区三区| 亚洲一级电影视频| 国产精品网友自拍| 精品少妇一区二区三区在线播放| 99热这里都是精品| 国产精品亚洲第一区在线暖暖韩国| 亚洲一区二区精品3399| 国产日韩欧美亚洲| 欧美成人午夜电影| 欧美福利电影网| 91麻豆国产福利在线观看| 国产一区二区三区观看| 日本美女一区二区三区视频| 亚洲精品视频在线看| 中文字幕成人在线观看| 久久你懂得1024| 欧美一区二区视频免费观看| 欧美综合视频在线观看| 不卡免费追剧大全电视剧网站| 精品一区二区三区蜜桃| 亚洲大尺度视频在线观看| 中文字幕制服丝袜一区二区三区| www日韩大片| 欧美电影免费提供在线观看| 欧美日本一道本在线视频| 91免费观看视频| www.66久久| av一二三不卡影片| 成人h动漫精品一区二区| 国产精品一二三区在线| 麻豆中文一区二区| 久久99热狠狠色一区二区| 日本91福利区| 久久精品国产999大香线蕉| 亚洲第一久久影院| 天堂在线亚洲视频| 免费在线看成人av| 免费欧美高清视频| 老司机精品视频一区二区三区| 麻豆国产欧美日韩综合精品二区| 天天色综合天天| 青娱乐精品在线视频| 蜜臀a∨国产成人精品| 久久精品国产亚洲高清剧情介绍| 美国十次了思思久久精品导航| 免费人成在线不卡| 国产在线观看免费一区| 国产精品一区二区久久不卡| 粉嫩嫩av羞羞动漫久久久| 福利一区福利二区| 色吊一区二区三区| 欧美三级韩国三级日本三斤| 欧美区视频在线观看| 日韩三级视频在线观看| 久久久五月婷婷| 国产精品久99| 午夜欧美在线一二页| 蜜臀av一区二区三区| 国产成人在线电影| 91丨九色丨蝌蚪丨老版| 欧美日韩在线三区| 久久亚区不卡日本| 亚洲色图在线看| 日韩国产欧美在线观看| 国产精品白丝jk黑袜喷水| 99精品在线观看视频| 欧美日韩日日夜夜| 欧美精彩视频一区二区三区| 综合av第一页| 麻豆精品在线视频| 99国产精品视频免费观看| 91精品国产一区二区人妖| 欧美极品少妇xxxxⅹ高跟鞋| 一区二区三区国产豹纹内裤在线| 日韩电影在线看| 成人丝袜高跟foot| 国产亚洲福利社区一区| 欧美丝袜丝交足nylons图片| 精品黑人一区二区三区久久 | 99在线热播精品免费| 91精品国产丝袜白色高跟鞋| 国产精品日日摸夜夜摸av| 日本亚洲天堂网| 色综合久久久久| 久久综合狠狠综合久久综合88| 1000精品久久久久久久久| 久久er精品视频| 欧美日韩情趣电影| 亚洲人成亚洲人成在线观看图片| 日韩精品国产欧美| 色综合天天综合| 欧美激情一区二区三区四区| 麻豆精品视频在线| 欧美日本韩国一区| 一区二区三区在线视频免费观看| 国产suv精品一区二区883| 日韩女优制服丝袜电影| 亚洲高清在线精品| 色8久久人人97超碰香蕉987| 久久久久99精品一区| 男女激情视频一区| 在线综合亚洲欧美在线视频| 亚洲综合在线视频| 色综合久久88色综合天天6| 国产精品毛片a∨一区二区三区| 精品亚洲成a人在线观看| 欧美一区二区三级| 日韩中文字幕不卡| 欧美电影影音先锋| 亚洲高清免费一级二级三级| 在线精品视频小说1| 亚洲欧洲日本在线| 99国产精品视频免费观看| 久久久久国产精品厨房| 国产精品18久久久久久久久久久久| 日韩精品一区二区三区在线播放 | 亚洲午夜在线观看视频在线| 色欧美日韩亚洲| 一区二区高清在线| 在线观看精品一区| 午夜视频久久久久久| 91精品国产色综合久久| 卡一卡二国产精品|