00001 /* 00002 openisis - an open implementation of the CDS/ISIS database 00003 Version 0.8.x (patchlevel see file Version) 00004 Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 see README for more information 00021 EOH */ 00022 #ifndef LBT_H 00023 00024 /* 00025 $Id: lbt.h,v 1.12 2003/05/27 11:03:30 kripke Exp $ 00026 package interface of the btree. 00027 see Lehmann/Yao or the GiST for how it works. 00028 */ 00029 00030 #include "ldb.h" /* LdbPost */ 00031 00032 00038 typedef int lbt_comp ( const unsigned char *a, const unsigned char *b, 00039 unsigned int l ); 00040 00048 typedef struct Idx { /* actually it's a B-L-Tree ;) */ 00049 int fd; /* the file */ 00050 int flg; /* flags: writeable, batch */ 00051 unsigned char typ; /* type: bsz, ifp, flags */ 00052 unsigned char key; /* max key length */ 00053 unsigned char col; /* collation */ 00054 unsigned char dpt; /* depth (level of root over bottom > 0) */ 00055 lbt_comp *cmp; /* comparision function */ 00056 /* following members (and the depth above) are set automatically. 00057 they are going to stay and you may check them, if you're interested. 00058 */ 00059 unsigned vsz; /* ifp size computed from type */ 00060 unsigned bsz; /* block size computed from type */ 00061 unsigned len; /* # blocks in index */ 00062 /* following members are considered internal. 00063 if you import lbt and rely on them, don't blame me if they change. 00064 */ 00065 unsigned hlen; /* hash length */ 00066 unsigned clen; /* cache length */ 00067 struct Block *root; /* the root */ 00068 struct Block **hash; /* hash array */ 00069 struct Block *lru[4]; /* least recently used list for lowest levels */ 00070 struct Block *mru[4]; /* tail of lru list (most recently used) */ 00071 struct Chunk *mem; 00072 struct Batch *bat; 00073 } Idx; 00074 00075 enum { /* btree flags */ 00076 LBT_WRITE = 0x01 /* open for writing */ 00077 }; 00078 enum { /* btree type */ 00079 LBT_BLK1K = 0x00, /* 1K blocks */ 00080 LBT_BLK2K = 0x10, /* 2K blocks */ 00081 LBT_BLK4K = 0x20, /* 4K blocks */ 00082 LBT_BLK8K = 0x30, /* 8K blocks */ 00083 LBT_CMPRS = 0x80 /* compressed keys */ 00084 }; 00085 00086 00087 00091 extern int lbt_init ( Idx *bt ); 00092 00096 extern void lbt_close ( Idx *bt ); 00097 00098 extern int lbt_batch ( Idx *bt, unsigned char pctfree ); 00099 extern int lbt_batchval ( Idx *bt, Key *key ); 00100 00101 extern int lbt_add ( Idx *bt, Key *key ); 00102 extern int lbt_del ( Idx *bt, Key *key ); 00103 00104 extern int lbt_loop ( Idx *bt, DXLoop *l ); 00105 extern int lbt_search ( Idx *bt, Key *key, LdbPost *post, Rec *rec ); 00106 00107 /* half public ... ??? */ 00108 extern void cXMkVal ( Idx *bt, Val *val, Hit *hit ); 00109 00110 #define LBT_H 00111 #endif /* LBT_H */