00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _DB_QAM_H_
00011 #define _DB_QAM_H_
00012
00013
00014
00015
00016 typedef struct _qamdata {
00017 u_int8_t flags;
00018 #define QAM_VALID 0x01
00019 #define QAM_SET 0x02
00020 u_int8_t data[1];
00021 } QAMDATA;
00022
00023 struct __queue; typedef struct __queue QUEUE;
00024 struct __qcursor; typedef struct __qcursor QUEUE_CURSOR;
00025
00026 struct __qcursor {
00027
00028 __DBC_INTERNAL
00029
00030
00031
00032
00033 db_recno_t recno;
00034
00035 u_int32_t flags;
00036 };
00037
00038 typedef struct __mpfarray {
00039 u_int32_t n_extent;
00040 u_int32_t low_extent;
00041 u_int32_t hi_extent;
00042 struct __qmpf {
00043 int pinref;
00044 DB_MPOOLFILE *mpf;
00045 } *mpfarray;
00046 } MPFARRAY;
00047
00048
00049
00050
00051 struct __queue {
00052 db_pgno_t q_meta;
00053 db_pgno_t q_root;
00054
00055 int re_pad;
00056 u_int32_t re_len;
00057 u_int32_t rec_page;
00058 u_int32_t page_ext;
00059 MPFARRAY array1, array2;
00060
00061
00062 DBT pgcookie;
00063 DB_PGINFO pginfo;
00064
00065 char *path;
00066 char *name;
00067 char *dir;
00068 int mode;
00069 };
00070
00071
00072 #define QUEUE_EXTENT "%s%c__dbq.%s.%d"
00073 #define QUEUE_EXTENT_HEAD "__dbq.%s."
00074
00075 typedef struct __qam_filelist {
00076 DB_MPOOLFILE *mpf;
00077 u_int32_t id;
00078 } QUEUE_FILELIST;
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #define CALC_QAM_RECNO_PER_PAGE(dbp) \
00096 (((dbp)->pgsize - QPAGE_SZ(dbp)) / \
00097 (u_int32_t)DB_ALIGN((uintmax_t)SSZA(QAMDATA, data) + \
00098 ((QUEUE *)(dbp)->q_internal)->re_len, sizeof(u_int32_t)))
00099
00100 #define QAM_RECNO_PER_PAGE(dbp) (((QUEUE*)(dbp)->q_internal)->rec_page)
00101
00102 #define QAM_RECNO_PAGE(dbp, recno) \
00103 (((QUEUE *)(dbp)->q_internal)->q_root \
00104 + (((recno) - 1) / QAM_RECNO_PER_PAGE(dbp)))
00105
00106 #define QAM_PAGE_EXTENT(dbp, pgno) \
00107 (((pgno) - 1) / ((QUEUE *)(dbp)->q_internal)->page_ext)
00108
00109 #define QAM_RECNO_EXTENT(dbp, recno) \
00110 QAM_PAGE_EXTENT(dbp, QAM_RECNO_PAGE(dbp, recno))
00111
00112 #define QAM_RECNO_INDEX(dbp, pgno, recno) \
00113 (((recno) - 1) - (QAM_RECNO_PER_PAGE(dbp) \
00114 * (pgno - ((QUEUE *)(dbp)->q_internal)->q_root)))
00115
00116 #define QAM_GET_RECORD(dbp, page, index) \
00117 ((QAMDATA *)((u_int8_t *)(page) + (QPAGE_SZ(dbp) + \
00118 (DB_ALIGN((uintmax_t)SSZA(QAMDATA, data) + \
00119 ((QUEUE *)(dbp)->q_internal)->re_len, sizeof(u_int32_t)) * index))))
00120
00121 #define QAM_AFTER_CURRENT(meta, recno) \
00122 ((recno) > (meta)->cur_recno && \
00123 ((meta)->first_recno <= (meta)->cur_recno || \
00124 ((recno) < (meta)->first_recno && \
00125 (recno) - (meta)->cur_recno < (meta)->first_recno - (recno))))
00126
00127 #define QAM_BEFORE_FIRST(meta, recno) \
00128 ((recno) < (meta)->first_recno && \
00129 ((meta->first_recno <= (meta)->cur_recno || \
00130 ((recno) > (meta)->cur_recno && \
00131 (recno) - (meta)->cur_recno > (meta)->first_recno - (recno)))))
00132
00133 #define QAM_NOT_VALID(meta, recno) \
00134 (recno == RECNO_OOB || \
00135 QAM_BEFORE_FIRST(meta, recno) || QAM_AFTER_CURRENT(meta, recno))
00136
00137
00138
00139
00140 #define QAM_SETFIRST 0x01
00141 #define QAM_SETCUR 0x02
00142 #define QAM_TRUNCATE 0x04
00143
00144
00145
00146
00147 typedef enum {
00148 QAM_READ,
00149 QAM_WRITE,
00150 QAM_CONSUME
00151 } qam_position_mode;
00152
00153 typedef enum {
00154 QAM_PROBE_GET,
00155 QAM_PROBE_PUT,
00156 QAM_PROBE_MPF
00157 } qam_probe_mode;
00158
00159
00160
00161
00162 typedef enum {
00163 QAM_NAME_DISCARD,
00164 QAM_NAME_RENAME,
00165 QAM_NAME_REMOVE
00166 } qam_name_op;
00167
00168 #define __qam_fget(dbp, pgnoaddr, flags, addrp) \
00169 __qam_fprobe(dbp, *pgnoaddr, addrp, QAM_PROBE_GET, flags)
00170
00171 #define __qam_fput(dbp, pageno, addrp, flags) \
00172 __qam_fprobe(dbp, pageno, addrp, QAM_PROBE_PUT, flags)
00173
00174 #include "dbinc_auto/qam_auto.h"
00175 #include "dbinc_auto/qam_ext.h"
00176 #endif