资源简介
基于ucOS与S3C44B0X的嵌入式数据库系统
代码片段和文件信息
/*
** 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 “eDbInit.h“
/* Forward declarations */
static BtOps eDbBtreeOps;
static BtCursorOps eDbBtreeCursorOps;
/*
** 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(BX) ((B)->needSwab? swab16((u16)X) : ((u16)X))
#define SWAB32(BX) ((B)->needSwab? swab32(X) : (X))
#define SWAB_ADD(BXA) \
if((B)->needSwab){ X=swab32(swab32(X)+A); }else{ X += (A); }
/*
** The following global variable - available only if eDb_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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
...D..R 0 2004-07-22 19:39 lemon
文件 8755 2004-07-09 09:55 lemon\parse.y
文件 3387 2004-03-30 18:05 lemon\lemon.dsp
文件 99328 2004-06-24 09:43 lemon\lemon.ncb
文件 1331 2004-06-24 09:43 lemon\lemon.plg
文件 533 2004-03-30 18:08 lemon\lemon.dsw
文件 63206 2004-07-09 09:55 lemon\parse.out
文件 2622 2004-07-07 14:08 lemon\parse.h
文件 15725 2004-06-22 16:08 lemon\eDbPparse.y
文件 36619 2004-07-09 09:55 lemon\parse.c
文件 128467 2004-06-24 09:43 lemon\lemon.c
文件 53760 2004-06-24 09:43 lemon\lemon.opt
文件 12344 2004-06-24 09:44 lemon\lempar.c
...D..R 0 2004-07-22 19:39 lemon\Release
...D..R 0 2004-07-22 19:39 lemon\Debug
...D..R 0 2004-07-19 16:55 test
文件 102400 2004-07-22 11:38 test\eDb.exe
文件 36864 2004-07-11 15:17 test\t.exe
目录 0 2005-05-12 19:06 uCOSeDb
文件 12325 2005-04-14 11:50 uCOSeDb\eDb.apj
目录 0 2005-05-12 19:06 uCOSeDb\Release
目录 0 2005-05-12 19:06 uCOSeDb\srcv
文件 28672 2004-09-16 14:37 uCOSeDb\srcv\edb.IMB
文件 608 2004-09-16 14:37 uCOSeDb\srcv\edb.IMD
文件 98304 2004-09-16 14:37 uCOSeDb\srcv\edb.IAB
文件 1288 2004-09-16 14:37 uCOSeDb\srcv\edb.IAD
文件 11432 2004-09-16 14:37 uCOSeDb\srcv\edb.PR
文件 227552 2004-09-16 14:37 uCOSeDb\srcv\edb.PS
文件 140 2004-09-16 14:37 uCOSeDb\srcv\edb.PFI
文件 776 2004-09-16 14:37 uCOSeDb\srcv\edb.PO
............此处省略196个文件信息
- 上一篇:qt通讯录实验
- 下一篇:银行家算法的设计与实现 操作系统课程设计
评论
共有 条评论