2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * db_index_entry_c.x
2N/A *
2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A%#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#if RPC_HDR
2N/A
2N/A%#ifndef _DB_INDEX_ENTRY_H
2N/A%#define _DB_INDEX_ENTRY_H
2N/A
2N/A%
2N/A% /* db_index_entry is an entry in the hashtable. db_index_entries can be
2N/A% linked in one of two ways:
2N/A% * via the 'next' pointer and form the hash bucket
2N/A% * via the 'nextresult' pointer and form a chain of results.
2N/A% Each entry contains the key, the hash value of key, and location
2N/A% information 'entryp'
2N/A% entryp is location information.
2N/A% It might be pointer to an in core entry, or an indirect pointer
2N/A% identifying the location of an entry somewhere in memory (e.g.
2N/A% if there was a table where all complete entries are stored) --- this
2N/A% is desirable, for example, for XDR operations on a multi-indexed table;
2N/A% or, if used in conjunction with NetISAM, it may be the record number. */
2N/A%/* *** notes */
2N/A%/* remember to set next_result to null first if using XDR. */
2N/A
2N/A#ifdef USINGC
2N/A%#include "db_item_c.h"
2N/A%#include "db_table_c.h" /* contains definition of entryp */
2N/A%typedef void *nullptr;
2N/A#else
2N/A%#include "db_item.h"
2N/A%#include "db_table.h" /* contains definition of entryp */
2N/A#endif /* USIGNC */
2N/A#endif /* RPC_HDR */
2N/A
2N/A
2N/A#if RPC_HDR || RPC_XDR
2N/A#ifdef USINGC
2N/Astruct db_index_entry {
2N/A unsigned long hashval;
2N/A item *key;
2N/A entryp location;
2N/A db_index_entry* next;
2N/A#ifdef USINGC
2N/A nullptr next_result;
2N/A#else
2N/A db_index_entry* next_result;
2N/A#endif
2N/A};
2N/Atypedef struct db_index_entry * db_index_entry_p;
2N/A#endif /* USINGC */
2N/A#endif /* RPC_HDR */
2N/A
2N/A#ifndef USINGC
2N/A#ifdef RPC_HDR
2N/A%class db_index_entry {
2N/A% unsigned long hashval;
2N/A% item *key;
2N/A% entryp location;
2N/A% db_index_entry* next;
2N/A% db_index_entry* next_result;
2N/A% public:
2N/A%
2N/A%/* Constructor: create an entry using given string and location info. */
2N/A% db_index_entry( char* name, int nlen, entryp location );
2N/A%
2N/A%/* Constructor: create an entry using the given info.
2N/A% A copy of the key is made. New entry is added to head of list of 'n'. */
2N/A% db_index_entry( unsigned long hval, item *, entryp, db_index_entry *n);
2N/A%
2N/A%/* Destructor: deletes key and itself. Assumes that deletion of
2N/A% object at location is done elsewhere (beforehand) */
2N/A% ~db_index_entry() {delete key; }
2N/A%
2N/A%/* Relocate bucket starting with this entry to new hashtable 'new_tab'. */
2N/A% void relocate( db_index_entry**, unsigned long );
2N/A%
2N/A%/* Join two lists (entry as identified by its 'location' occurs on both list,
2N/A% then it is included in the list returned).
2N/A% Returns pointer to resulting list; size of list
2N/A% returned in 'newsize'. List is chained using the 'nextresult' pointer. */
2N/A% db_index_entry* join( long size1, long size2, db_index_entry *list2,
2N/A% long * newsize );
2N/A%
2N/A%/* Returns pointer to a list of index entries with the same hash value and
2N/A% key as those given. Returns in 'how_many' the number of entries in the
2N/A% list returned. The list is linked by the 'next_result' field of the
2N/A% index entries. These may be changed after the next call to 'lookup'
2N/A% or 'join'. */
2N/A% db_index_entry* lookup( bool_t, unsigned long, item*, long *);
2N/A%
2N/A%/* Return pointer to index entry with same hash value, same key,
2N/A% and same record number as those supplied. Returns NULL if not found. */
2N/A% db_index_entry* lookup( bool_t, unsigned long, item*, entryp ); //name entry
2N/A%
2N/A%/* Return the next entry in the bucket starting with this entry
2N/A% with the same hashvalue, key and location as this entry. */
2N/A% db_index_entry* getnext( bool_t, unsigned long, item*, entryp );
2N/A%
2N/A%/* Return the next entry in the bucket. */
2N/A% db_index_entry* getnextentry() {return next;}
2N/A%
2N/A%/* Return the next entry in the 'next_result' chain. */
2N/A% db_index_entry* getnextresult() {return next_result;}
2N/A%
2N/A%/* Return the location field of this entry. */
2N/A% entryp getlocation() {return location;}
2N/A%
2N/A%/* Assign the given pointer as the next result after this entry. */
2N/A% void addresult( db_index_entry * nr ) { next_result = nr; }
2N/A%
2N/A%/* Return the pointer to the key of this entry. */
2N/A% item * get_key() {return key;}
2N/A%
2N/A%/* Remove entry with the specified hashvalue, key, and record number.
2N/A% Returns 'TRUE' if successful, FALSE otherwise.
2N/A% If the entry being removed is at the head of the list, then
2N/A% the head is updated to reflect the removal. The storage for the index
2N/A% entry is freed. The record pointed to by 'recnum' must be removed
2N/A% through another means. All that is updated in this operation is the
2N/A% index. */
2N/A% bool_t remove( db_index_entry **, bool_t, unsigned long, item *, entryp );
2N/A%
2N/A%/* Replace the 'location' field of the index entry with the given one. */
2N/A% void replace( entryp ep ) {location = ep;}
2N/A%
2N/A%/* Create and add an entry with the given hashvalue, key value, and record
2N/A% location, to the bucket pointed to by 'hashvalue'.
2N/A% If an entry with the same identical information is found, no addition
2N/A% is done. If an entry with the same hashvalue and key value is found,
2N/A% the entry is added after the first entry with this property. Otherwise,
2N/A% the entry is added to the head of the bucket. This way, entries
2N/A% with the same hashvalue and key are not scattered throughout the bucket
2N/A% but they occur together. Copy is made of given key. */
2N/A% bool_t add( db_index_entry **oldhead, bool_t, unsigned long hval, item *,
2N/A% entryp );
2N/A%
2N/A%/* Print this entry to stdout. */
2N/A% void print();
2N/A%
2N/A%/* Print bucket starting with this entry. */
2N/A% void print_all();
2N/A%
2N/A%/* Print result list starting with this entry. */
2N/A% void print_results();
2N/A%};
2N/A%typedef class db_index_entry * db_index_entry_p;
2N/A#endif /* RPC_HDR */
2N/A#endif /* USINGC */
2N/A
2N/A#if RPC_HDR
2N/A%#endif /* _DB_INDEX_ENTRY_H */
2N/A#endif /* RPC_HDR */