#define ELEMPERCLUST 42 //42 elements per cluster
#define CLUSTERSIZE 1024 //cluster size obviously
:)[/QUOTE]
So far, so goed. Dump the smileys, though. If this is professional
code, don't try to be cute.
[QUOTE]
#define MAXWORDLEN 22 //maximum word length
#define NUMLEVELS 3 //number of index
levels[/QUOTE]
A more usefull comment would explain _why_ there are only three levels.
Why not simply used qsort and bsearch? Why require a homegrown indexing
method?
[QUOTE]
#define WORDLEV (NUMLEVELS-1) //words are on level 2 (3-1 =
2)
struct element {
int index; // cluster index
char word[MAXWORDLEN];
};[/QUOTE]
This will give you a lot of overhead, since MAXWORDLEN must be large
enough to hold the longest word and most words will be much shorter.
Isn't there a better alternative? Does the content change frequently?
If not, why not record all the words in one big buffer, separated by
'\0' and simply use a char*? Also why do you store the 'cluster index'
in the element? It's not clear from what you write here, so at least
there should be a comment, explaining that.
[QUOTE]
struct cluster {
int indexclust; //Set to 1 for index clust or 0 for words
struct element elem[ELEMPERCLUST];
} clust[NUMLEVELS]; // 2 index levels 0, 1 plus the word level 2[/QUOTE]
Obviously you know (from the index of 'clust') whether you are dealing
with an 'index clust' or a word, so the first field seems superfluous.
Unless of course you are planning to domething incredibly clever, I do
not see.
[QUOTE]
int fd, clust_pos, nincluster[NUMLEVELS], location[NUMLEVELS];[/QUOTE]
It's generally a good idea to define only one variable per line. That
will make your code easier to read. After all, you write in C fro the
benefit of humans, not computers.
[QUOTE]
void isam_output(int lev, char *word, int index) {
//Time to write the index and data clusters for words
}[/QUOTE]
How do you signal an error? If you write to a stream, any number of
things can go wrong. Failing silently virtually guarantees BIG
problems. Also, your interface requires you to know the index before
you've written anything. Now you could be planning something incredibly
clever, but from what you post here, i don't think it's a very useable
interface. Usually the index is a _result_ of writing a record.
[QUOTE]