/* * Please do not edit this file. * It was generated using rpcgen. */ #ifndef _DB_INDEX_ENTRY_H_RPCGEN #define _DB_INDEX_ENTRY_H_RPCGEN #include #pragma ident "%Z%%M% %I% %E% SMI" #ifndef _DB_INDEX_ENTRY_H #define _DB_INDEX_ENTRY_H /* db_index_entry is an entry in the hashtable. db_index_entries can be linked in one of two ways: * via the 'next' pointer and form the hash bucket * via the 'nextresult' pointer and form a chain of results. Each entry contains the key, the hash value of key, and location information 'entryp' entryp is location information. It might be pointer to an in core entry, or an indirect pointer identifying the location of an entry somewhere in memory (e.g. if there was a table where all complete entries are stored) --- this is desirable, for example, for XDR operations on a multi-indexed table; or, if used in conjunction with NetISAM, it may be the record number. */ /* *** notes */ /* remember to set next_result to null first if using XDR. */ #include "db_item.h" #include "db_table.h" /* contains definition of entryp */ class db_index_entry { unsigned long hashval; item *key; entryp location; db_index_entry* next; db_index_entry* next_result; public: /* Constructor: create an entry using given string and location info. */ db_index_entry( char* name, int nlen, entryp location ); /* Constructor: create an entry using the given info. A copy of the key is made. New entry is added to head of list of 'n'. */ db_index_entry( unsigned long hval, item *, entryp, db_index_entry *n); /* Destructor: deletes key and itself. Assumes that deletion of object at location is done elsewhere (beforehand) */ ~db_index_entry() {delete key; } /* Relocate bucket starting with this entry to new hashtable 'new_tab'. */ void relocate( db_index_entry**, unsigned long ); /* Join two lists (entry as identified by its 'location' occurs on both list, then it is included in the list returned). Returns pointer to resulting list; size of list returned in 'newsize'. List is chained using the 'nextresult' pointer. */ db_index_entry* join( long size1, long size2, db_index_entry *list2, long * newsize ); /* Returns pointer to a list of index entries with the same hash value and key as those given. Returns in 'how_many' the number of entries in the list returned. The list is linked by the 'next_result' field of the index entries. These may be changed after the next call to 'lookup' or 'join'. */ db_index_entry* lookup( bool_t, unsigned long, item*, long *); /* Return pointer to index entry with same hash value, same key, and same record number as those supplied. Returns NULL if not found. */ db_index_entry* lookup( bool_t, unsigned long, item*, entryp ); //name entry /* Return the next entry in the bucket starting with this entry with the same hashvalue, key and location as this entry. */ db_index_entry* getnext( bool_t, unsigned long, item*, entryp ); /* Return the next entry in the bucket. */ db_index_entry* getnextentry() {return next;} /* Return the next entry in the 'next_result' chain. */ db_index_entry* getnextresult() {return next_result;} /* Return the location field of this entry. */ entryp getlocation() {return location;} /* Assign the given pointer as the next result after this entry. */ void addresult( db_index_entry * nr ) { next_result = nr; } /* Return the pointer to the key of this entry. */ item * get_key() {return key;} /* Remove entry with the specified hashvalue, key, and record number. Returns 'TRUE' if successful, FALSE otherwise. If the entry being removed is at the head of the list, then the head is updated to reflect the removal. The storage for the index entry is freed. The record pointed to by 'recnum' must be removed through another means. All that is updated in this operation is the index. */ bool_t remove( db_index_entry **, bool_t, unsigned long, item *, entryp ); /* Replace the 'location' field of the index entry with the given one. */ void replace( entryp ep ) {location = ep;} /* Create and add an entry with the given hashvalue, key value, and record location, to the bucket pointed to by 'hashvalue'. If an entry with the same identical information is found, no addition is done. If an entry with the same hashvalue and key value is found, the entry is added after the first entry with this property. Otherwise, the entry is added to the head of the bucket. This way, entries with the same hashvalue and key are not scattered throughout the bucket but they occur together. Copy is made of given key. */ bool_t add( db_index_entry **oldhead, bool_t, unsigned long hval, item *, entryp ); /* Print this entry to stdout. */ void print(); /* Print bucket starting with this entry. */ void print_all(); /* Print result list starting with this entry. */ void print_results(); }; typedef class db_index_entry * db_index_entry_p; #endif /* _DB_INDEX_ENTRY_H */ #endif /* !_DB_INDEX_ENTRY_H_RPCGEN */