1 /* 2 * Please do not edit this file. 3 * It was generated using rpcgen. 4 */ 5 6 #ifndef _DB_INDEX_ENTRY_H_RPCGEN 7 #define _DB_INDEX_ENTRY_H_RPCGEN 8 9 #include <rpc/rpc.h> 10 #pragma ident "%Z%%M% %I% %E% SMI" 11 #ifndef _DB_INDEX_ENTRY_H 12 #define _DB_INDEX_ENTRY_H 13 14 /* db_index_entry is an entry in the hashtable. db_index_entries can be 15 linked in one of two ways: 16 * via the 'next' pointer and form the hash bucket 17 * via the 'nextresult' pointer and form a chain of results. 18 Each entry contains the key, the hash value of key, and location 19 information 'entryp' 20 entryp is location information. 21 It might be pointer to an in core entry, or an indirect pointer 22 identifying the location of an entry somewhere in memory (e.g. 23 if there was a table where all complete entries are stored) --- this 24 is desirable, for example, for XDR operations on a multi-indexed table; 25 or, if used in conjunction with NetISAM, it may be the record number. */ 26 /* *** notes */ 27 /* remember to set next_result to null first if using XDR. */ 28 #include "db_item.h" 29 #include "db_table.h" /* contains definition of entryp */ 30 class db_index_entry { 31 unsigned long hashval; 32 item *key; 33 entryp location; 34 db_index_entry* next; 35 db_index_entry* next_result; 36 public: 37 38 /* Constructor: create an entry using given string and location info. */ 39 db_index_entry( char* name, int nlen, entryp location ); 40 41 /* Constructor: create an entry using the given info. 42 A copy of the key is made. New entry is added to head of list of 'n'. */ 43 db_index_entry( unsigned long hval, item *, entryp, db_index_entry *n); 44 45 /* Destructor: deletes key and itself. Assumes that deletion of 46 object at location is done elsewhere (beforehand) */ 47 ~db_index_entry() {delete key; } 48 49 /* Relocate bucket starting with this entry to new hashtable 'new_tab'. */ 50 void relocate( db_index_entry**, unsigned long ); 51 52 /* Join two lists (entry as identified by its 'location' occurs on both list, 53 then it is included in the list returned). 54 Returns pointer to resulting list; size of list 55 returned in 'newsize'. List is chained using the 'nextresult' pointer. */ 56 db_index_entry* join( long size1, long size2, db_index_entry *list2, 57 long * newsize ); 58 59 /* Returns pointer to a list of index entries with the same hash value and 60 key as those given. Returns in 'how_many' the number of entries in the 61 list returned. The list is linked by the 'next_result' field of the 62 index entries. These may be changed after the next call to 'lookup' 63 or 'join'. */ 64 db_index_entry* lookup( bool_t, unsigned long, item*, long *); 65 66 /* Return pointer to index entry with same hash value, same key, 67 and same record number as those supplied. Returns NULL if not found. */ 68 db_index_entry* lookup( bool_t, unsigned long, item*, entryp ); //name entry 69 70 /* Return the next entry in the bucket starting with this entry 71 with the same hashvalue, key and location as this entry. */ 72 db_index_entry* getnext( bool_t, unsigned long, item*, entryp ); 73 74 /* Return the next entry in the bucket. */ 75 db_index_entry* getnextentry() {return next;} 76 77 /* Return the next entry in the 'next_result' chain. */ 78 db_index_entry* getnextresult() {return next_result;} 79 80 /* Return the location field of this entry. */ 81 entryp getlocation() {return location;} 82 83 /* Assign the given pointer as the next result after this entry. */ 84 void addresult( db_index_entry * nr ) { next_result = nr; } 85 86 /* Return the pointer to the key of this entry. */ 87 item * get_key() {return key;} 88 89 /* Remove entry with the specified hashvalue, key, and record number. 90 Returns 'TRUE' if successful, FALSE otherwise. 91 If the entry being removed is at the head of the list, then 92 the head is updated to reflect the removal. The storage for the index 93 entry is freed. The record pointed to by 'recnum' must be removed 94 through another means. All that is updated in this operation is the 95 index. */ 96 bool_t remove( db_index_entry **, bool_t, unsigned long, item *, entryp ); 97 98 /* Replace the 'location' field of the index entry with the given one. */ 99 void replace( entryp ep ) {location = ep;} 100 101 /* Create and add an entry with the given hashvalue, key value, and record 102 location, to the bucket pointed to by 'hashvalue'. 103 If an entry with the same identical information is found, no addition 104 is done. If an entry with the same hashvalue and key value is found, 105 the entry is added after the first entry with this property. Otherwise, 106 the entry is added to the head of the bucket. This way, entries 107 with the same hashvalue and key are not scattered throughout the bucket 108 but they occur together. Copy is made of given key. */ 109 bool_t add( db_index_entry **oldhead, bool_t, unsigned long hval, item *, 110 entryp ); 111 112 /* Print this entry to stdout. */ 113 void print(); 114 115 /* Print bucket starting with this entry. */ 116 void print_all(); 117 118 /* Print result list starting with this entry. */ 119 void print_results(); 120 }; 121 typedef class db_index_entry * db_index_entry_p; 122 #endif /* _DB_INDEX_ENTRY_H */ 123 124 #endif /* !_DB_INDEX_ENTRY_H_RPCGEN */ 125