/[webpac]/trunk/openisis/lbt.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/openisis/lbt.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 239 - (show annotations)
Mon Mar 8 17:49:13 2004 UTC (20 years ago) by dpavlin
File MIME type: text/plain
File size: 3489 byte(s)
including openisis 0.9.0 into webpac tree

1 /*
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
5
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.
10
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.
15
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
19
20 see README for more information
21 EOH */
22 #ifndef LBT_H
23
24 /*
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.
28 */
29
30 #include "ldb.h" /* LdbPost */
31
32
33 /**
34 key comparision function.
35 however, we still assume that two keys have to be identical
36 in length and bytes to be equal.
37 */
38 typedef int lbt_comp ( const unsigned char *a, const unsigned char *b,
39 unsigned int l );
40
41 /**
42 variables:
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
47 */
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.
58 */
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.
64 */
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) */
71 struct Chunk *mem;
72 struct Batch *bat;
73 } Idx;
74
75 enum { /* btree flags */
76 LBT_WRITE = 0x01 /* open for writing */
77 };
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 */
84 };
85
86
87
88 /**
89 initialise from an already open fd.
90 */
91 extern int lbt_init ( Idx *bt );
92
93 /**
94 flush and release any cache, close fd.
95 */
96 extern void lbt_close ( Idx *bt );
97
98 extern int lbt_batch ( Idx *bt, unsigned char pctfree );
99 extern int lbt_batchval ( Idx *bt, Key *key );
100
101 extern int lbt_add ( Idx *bt, Key *key );
102 extern int lbt_del ( Idx *bt, Key *key );
103
104 extern int lbt_loop ( Idx *bt, DXLoop *l );
105 extern int lbt_search ( Idx *bt, Key *key, LdbPost *post, Rec *rec );
106
107 /* half public ... ??? */
108 extern void cXMkVal ( Idx *bt, Val *val, Hit *hit );
109
110 #define LBT_H
111 #endif /* LBT_H */

  ViewVC Help
Powered by ViewVC 1.1.26