home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / WAIS / ir / hutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-02  |  2.7 KB  |  73 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    Brewster@think.com
  6. */
  7.  
  8. /* Hash table utilities */
  9.  
  10. #ifndef HUTIL_H
  11. #define HUTIL_H
  12.  
  13. #include "irlex.h" /* for MAX_WORD_LENGTH */
  14.  
  15. /* this is the size of the memory word hashtable.  
  16.  * It will be grown if needed.
  17.  */
  18. #define HASHTABLE_INITIAL_SIZE 65536L
  19.  
  20. /* the amount of memory for word occurances (bytes) */
  21. #define WORD_MEMORY_INIT_BLOCK_SIZE 10
  22.  
  23. /* this is the maximum number of occurances that will be stored in the 
  24.  * disk table.  The number of occurances will reflect the total number in
  25.  * all files.  The theory is that if a word is very common, then it
  26.  * is not very useful in descriminating between files.  Also, if it
  27.  * is very common, then it takes up alot of space.
  28.  * Maybe this should be dependent on the number of documents indexed.
  29.  * Therefore if a word is in every document, then it probably does not mean
  30.  * much.  
  31.  * In increasing this, it may not keep all the references in the 
  32.  * inverted file because the max length of an index block is governed
  33.  * by a size that can be represented in INDEX_BLOCK_SIZE_SIZE bytes.
  34.  */
  35. #define MAX_OCCURANCES 20000L
  36.  
  37. #define STOP_WORD_FLAG 0x40000000  /* this is a flag to be put in the number_of_occurances field of a word_entry so that it is always greater than the limit
  38. and no words will be collected. */
  39.  
  40. typedef struct word_entry{
  41.   char word[MAX_WORD_LENGTH + 1];    /* NULL when empty. Must be 
  42.                        the first slot */
  43.   /* should this be the total weight? */
  44.   long hash_code;
  45.   long number_of_occurances;    /* total for the whole db */
  46.  
  47.   char* memory_ptr;        /* what will go into the next block */
  48.   char* current_memory_ptr;    /* the fill ptr into memory_ptr */
  49.   long memory_size;        /* the size of memory_ptr */
  50.   long current_doc_id;        /* the last document-id in memory_ptr
  51.                  * this will change a page pointer eventually
  52.                  */
  53. } word_entry;
  54.  
  55. typedef struct word_memory_hashtable{
  56.   long size;    /* number of elements that can be in the contents */
  57.   long word_entry_block_size;  /* the maximum number of entries before flushing */
  58.   long number_of_entries;    /* number of elements that are in the 
  59.                  * contents.
  60.                  */
  61.   word_entry** contents;    /* pointer to the word hashtable memory */
  62.   word_entry *word_entry_block;    /* pointer block of entries */
  63.   long number_of_words_indexed; /* total number of words indexed */
  64.   long flush_after_n_words;     /* number of words that should be accumulated
  65.                  * before flushing.  This should be dynamically
  66.                  * handled rather than this way.
  67.                  */
  68.   double growth_factor;        /* amount to grow when growing */
  69.   double grow_when_this_full;     /* fraction of full that triggers growth */
  70. } word_memory_hashtable;
  71.  
  72. #endif /* ndef HUTIL_H */
  73.