2 openisis - an open implementation of the CDS/ISIS database
3 Version 0.8.x (patchlevel see file Version)
4 Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 see README for more information
25 $Id: lbt.h,v 1.12 2003/05/27 11:03:30 kripke Exp $
26 package interface of the btree.
27 see Lehmann/Yao or the GiST for how it works.
30 #include "ldb.h" /* LdbPost */
34 key comparision function.
35 however, we still assume that two keys have to be identical
36 in length and bytes to be equal.
38 typedef int lbt_comp ( const unsigned char *a, const unsigned char *b,
43 4 bits: #bytes for value 8+(0..15)
44 2 bits: blocksize 1024<<(0..3)
45 max key length (4..255)
46 collation (comparision function) 0..255
48 typedef struct Idx { /* actually it's a B-L-Tree ;) */
49 int fd; /* the file */
50 int flg; /* flags: writeable, batch */
51 unsigned char typ; /* type: bsz, ifp, flags */
52 unsigned char key; /* max key length */
53 unsigned char col; /* collation */
54 unsigned char dpt; /* depth (level of root over bottom > 0) */
55 lbt_comp *cmp; /* comparision function */
56 /* following members (and the depth above) are set automatically.
57 they are going to stay and you may check them, if you're interested.
59 unsigned vsz; /* ifp size computed from type */
60 unsigned bsz; /* block size computed from type */
61 unsigned len; /* # blocks in index */
62 /* following members are considered internal.
63 if you import lbt and rely on them, don't blame me if they change.
65 unsigned hlen; /* hash length */
66 unsigned clen; /* cache length */
67 struct Block *root; /* the root */
68 struct Block **hash; /* hash array */
69 struct Block *lru[4]; /* least recently used list for lowest levels */
70 struct Block *mru[4]; /* tail of lru list (most recently used) */
75 enum { /* btree flags */
76 LBT_WRITE = 0x01 /* open for writing */
78 enum { /* btree type */
79 LBT_BLK1K = 0x00, /* 1K blocks */
80 LBT_BLK2K = 0x10, /* 2K blocks */
81 LBT_BLK4K = 0x20, /* 4K blocks */
82 LBT_BLK8K = 0x30, /* 8K blocks */
83 LBT_CMPRS = 0x80 /* compressed keys */
89 initialise from an already open fd.
91 extern int lbt_init ( Idx *bt );
94 flush and release any cache, close fd.
96 extern void lbt_close ( Idx *bt );
98 extern int lbt_batch ( Idx *bt, unsigned char pctfree );
99 extern int lbt_batchval ( Idx *bt, Key *key );
101 extern int lbt_add ( Idx *bt, Key *key );
102 extern int lbt_del ( Idx *bt, Key *key );
104 extern int lbt_loop ( Idx *bt, DXLoop *l );
105 extern int lbt_search ( Idx *bt, Key *key, LdbPost *post, Rec *rec );
107 /* half public ... ??? */
108 extern void cXMkVal ( Idx *bt, Val *val, Hit *hit );