db

qam.h

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1999, 2000
00005  * Sleepycat Software. All rights reserved.
00006  *
00007  * $Id: qam_8h-source.html,v 1.1 2008年06月08日 10:21:36 sebdiaz Exp $
00008  */
00009 
00010 /*
00011  * QAM data elements: a status field and the data.
00012  */
00013 typedef struct _qamdata {
00014 u_int8_t flags; /* 00: delete bit. */
00015 #define QAM_VALID 0x01
00016 #define QAM_SET 0x02
00017 u_int8_t data[1]; /* Record. */
00018 } QAMDATA;
00019 
00020 struct __queue; typedef struct __queue QUEUE;
00021 struct __qcursor; typedef struct __qcursor QUEUE_CURSOR;
00022 
00023 struct __qcursor {
00024 /* struct __dbc_internal */
00025 __DBC_INTERNAL
00026 
00027 /* Queue private part */
00028 
00029 /* Per-thread information: queue private. */
00030 db_recno_t start; /* start record number. */
00031 db_recno_t recno; /* Current record number. */
00032 
00033 u_int32_t flags;
00034 };
00035 
00036 /*
00037  * The in-memory, per-tree queue data structure.
00038  */
00039 struct __queue {
00040 db_pgno_t q_meta; /* Database meta-data page. */
00041 db_pgno_t q_root; /* Database root page. */
00042 
00043 int re_pad; /* Fixed-length padding byte. */
00044 u_int32_t re_len; /* Length for fixed-length records. */
00045 u_int32_t rec_page; /* records per page */
00046 };
00047 
00048 /*
00049  * Caculate the page number of a recno
00050  *
00051  * Number of records per page =
00052  * Divide the available space on the page by the record len + header.
00053  *
00054  * Page number for record =
00055  * divide the physical record number by the records per page
00056  * add the root page number
00057  * For now the root page will always be 1, but we might want to change
00058  * in the future (e.g. multiple fixed len queues per file).
00059  *
00060  * Index of record on page =
00061  * physical record number, less the logical pno times records/page
00062  */
00063 #define CALC_QAM_RECNO_PER_PAGE(dbp) \
00064  (((dbp)->pgsize - sizeof(QPAGE)) / \
00065  ALIGN(((QUEUE *)(dbp)->q_internal)->re_len + \
00066  sizeof(QAMDATA) - SSZA(QAMDATA, data), sizeof(u_int32_t)))
00067 
00068 #define QAM_RECNO_PER_PAGE(dbp) (((QUEUE*)(dbp)->q_internal)->rec_page)
00069 
00070 #define QAM_RECNO_PAGE(dbp, start, recno) \
00071  (((QUEUE *)(dbp)->q_internal)->q_root \
00072  + (((recno) - (start)) / QAM_RECNO_PER_PAGE(dbp)))
00073 
00074 #define QAM_RECNO_INDEX(dbp, pgno, start, recno) \
00075  (((recno) - (start)) - (QAM_RECNO_PER_PAGE(dbp) \
00076  * (pgno - ((QUEUE *)(dbp)->q_internal)->q_root)))
00077 
00078 #define QAM_GET_RECORD(dbp, page, index) \
00079  ((QAMDATA *)((u_int8_t *)(page) + \
00080  sizeof(QPAGE) + (ALIGN(sizeof(QAMDATA) - SSZA(QAMDATA, data) + \
00081  ((QUEUE *)(dbp)->q_internal)->re_len, sizeof(u_int32_t)) * index)))
00082 
00083 /*
00084  * Log opcodes for the mvptr routine.
00085  */
00086 #define QAM_SETFIRST 0x01
00087 #define QAM_SETCUR 0x02
00088 
00089 #include "qam_auto.h"
00090 #include "qam_ext.h"

Generated on Sun Jun 8 10:56:38 2008 for GNUmifluz by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /