| Revision 337 (by dpavlin, 2004/06/10 19:22:40) |
new trunk for webpac v2
|
/*
openisis - an open implementation of the CDS/ISIS database
Version 0.8.x (patchlevel see file Version)
Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
see README for more information
EOH */
#ifndef LBT_H
/*
$Id: lbt.h,v 1.12 2003/05/27 11:03:30 kripke Exp $
package interface of the btree.
see Lehmann/Yao or the GiST for how it works.
*/
#include "ldb.h" /* LdbPost */
/**
key comparision function.
however, we still assume that two keys have to be identical
in length and bytes to be equal.
*/
typedef int lbt_comp ( const unsigned char *a, const unsigned char *b,
unsigned int l );
/**
variables:
4 bits: #bytes for value 8+(0..15)
2 bits: blocksize 1024<<(0..3)
max key length (4..255)
collation (comparision function) 0..255
*/
typedef struct Idx { /* actually it's a B-L-Tree ;) */
int fd; /* the file */
int flg; /* flags: writeable, batch */
unsigned char typ; /* type: bsz, ifp, flags */
unsigned char key; /* max key length */
unsigned char col; /* collation */
unsigned char dpt; /* depth (level of root over bottom > 0) */
lbt_comp *cmp; /* comparision function */
/* following members (and the depth above) are set automatically.
they are going to stay and you may check them, if you're interested.
*/
unsigned vsz; /* ifp size computed from type */
unsigned bsz; /* block size computed from type */
unsigned len; /* # blocks in index */
/* following members are considered internal.
if you import lbt and rely on them, don't blame me if they change.
*/
unsigned hlen; /* hash length */
unsigned clen; /* cache length */
struct Block *root; /* the root */
struct Block **hash; /* hash array */
struct Block *lru[4]; /* least recently used list for lowest levels */
struct Block *mru[4]; /* tail of lru list (most recently used) */
struct Chunk *mem;
struct Batch *bat;
} Idx;
enum { /* btree flags */
LBT_WRITE = 0x01 /* open for writing */
};
enum { /* btree type */
LBT_BLK1K = 0x00, /* 1K blocks */
LBT_BLK2K = 0x10, /* 2K blocks */
LBT_BLK4K = 0x20, /* 4K blocks */
LBT_BLK8K = 0x30, /* 8K blocks */
LBT_CMPRS = 0x80 /* compressed keys */
};
/**
initialise from an already open fd.
*/
extern int lbt_init ( Idx *bt );
/**
flush and release any cache, close fd.
*/
extern void lbt_close ( Idx *bt );
extern int lbt_batch ( Idx *bt, unsigned char pctfree );
extern int lbt_batchval ( Idx *bt, Key *key );
extern int lbt_add ( Idx *bt, Key *key );
extern int lbt_del ( Idx *bt, Key *key );
extern int lbt_loop ( Idx *bt, DXLoop *l );
extern int lbt_search ( Idx *bt, Key *key, LdbPost *post, Rec *rec );
/* half public ... ??? */
extern void cXMkVal ( Idx *bt, Val *val, Hit *hit );
#define LBT_H
#endif /* LBT_H */