diff options
Diffstat (limited to 'innobase/ha')
-rw-r--r-- | innobase/ha/ha0ha.c | 36 | ||||
-rw-r--r-- | innobase/ha/hash0hash.c | 38 | ||||
-rw-r--r-- | innobase/ha/ts/makefile | 12 | ||||
-rw-r--r-- | innobase/ha/ts/tsha.c | 120 |
4 files changed, 12 insertions, 194 deletions
diff --git a/innobase/ha/ha0ha.c b/innobase/ha/ha0ha.c index 3f36879e80b..5e807406ce0 100644 --- a/innobase/ha/ha0ha.c +++ b/innobase/ha/ha0ha.c @@ -66,33 +66,6 @@ ha_create( } /***************************************************************** -Checks that a hash table node is in the chain. */ - -ibool -ha_node_in_chain( -/*=============*/ - /* out: TRUE if in chain */ - hash_cell_t* cell, /* in: hash table cell */ - ha_node_t* node) /* in: external chain node */ -{ - ha_node_t* node2; - - node2 = cell->node; - - while (node2 != NULL) { - - if (node2 == node) { - - return(TRUE); - } - - node2 = node2->next; - } - - return(FALSE); -} - -/***************************************************************** Inserts an entry into a hash table. If an entry with the same fold number is found, its node is updated to point to the new data, and no new node is inserted. */ @@ -116,8 +89,9 @@ ha_insert_for_fold( ulint hash; ut_ad(table && data); +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); - +#endif /* UNIV_SYNC_DEBUG */ hash = hash_calc_hash(fold, table); cell = hash_get_nth_cell(table, hash); @@ -213,8 +187,9 @@ ha_delete( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); - +#endif /* UNIV_SYNC_DEBUG */ node = ha_search_with_data(table, fold, data); ut_a(node); @@ -264,8 +239,9 @@ ha_remove_all_nodes_to_page( { ha_node_t* node; +#ifdef UNIV_SYNC_DEBUG ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold))); - +#endif /* UNIV_SYNC_DEBUG */ node = ha_chain_get_first(table, fold); while (node) { diff --git a/innobase/ha/hash0hash.c b/innobase/ha/hash0hash.c index facdea66198..372104e54b3 100644 --- a/innobase/ha/hash0hash.c +++ b/innobase/ha/hash0hash.c @@ -22,6 +22,7 @@ hash_mutex_enter( hash_table_t* table, /* in: hash table */ ulint fold) /* in: fold */ { + ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); mutex_enter(hash_get_mutex(table, fold)); } @@ -34,41 +35,10 @@ hash_mutex_exit( hash_table_t* table, /* in: hash table */ ulint fold) /* in: fold */ { + ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); mutex_exit(hash_get_mutex(table, fold)); } -/**************************************************************** -Reserves all the mutexes of a hash table, in an ascending order. */ - -void -hash_mutex_enter_all( -/*=================*/ - hash_table_t* table) /* in: hash table */ -{ - ulint i; - - for (i = 0; i < table->n_mutexes; i++) { - - mutex_enter(table->mutexes + i); - } -} - -/**************************************************************** -Releases all the mutexes of a hash table. */ - -void -hash_mutex_exit_all( -/*================*/ - hash_table_t* table) /* in: hash table */ -{ - ulint i; - - for (i = 0; i < table->n_mutexes; i++) { - - mutex_exit(table->mutexes + i); - } -} - /***************************************************************** Creates a hash table with >= n array cells. The actual number of cells is chosen to be a prime number slightly bigger than n. */ @@ -98,7 +68,9 @@ hash_create( table->mutexes = NULL; table->heaps = NULL; table->heap = NULL; +#ifdef UNIV_DEBUG table->magic_n = HASH_TABLE_MAGIC_N; +#endif /* UNIV_DEBUG */ /* Initialize the cell array */ @@ -119,6 +91,7 @@ hash_table_free( /*============*/ hash_table_t* table) /* in, own: hash table */ { + ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); ut_a(table->mutexes == NULL); ut_free(table->array); @@ -140,6 +113,7 @@ hash_create_mutexes( ulint i; ut_a(n_mutexes == ut_2_power_up(n_mutexes)); + ut_ad(table->magic_n == HASH_TABLE_MAGIC_N); table->mutexes = mem_alloc(n_mutexes * sizeof(mutex_t)); diff --git a/innobase/ha/ts/makefile b/innobase/ha/ts/makefile deleted file mode 100644 index aea21f11141..00000000000 --- a/innobase/ha/ts/makefile +++ /dev/null @@ -1,12 +0,0 @@ - -include ..\..\makefile.i - -tsha: ..\ha.lib tsha.c makefile - $(CCOM) $(CFL) -I.. -I..\.. ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsha.c $(LFL) - - - - - - - diff --git a/innobase/ha/ts/tsha.c b/innobase/ha/ts/tsha.c deleted file mode 100644 index fd9a2e12f6e..00000000000 --- a/innobase/ha/ts/tsha.c +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************ -The test module for hash table - -(c) 1994, 1995 Innobase Oy - -Created 1/25/1994 Heikki Tuuri -*************************************************************************/ - -#include "ut0ut.h" -#include "ha0ha.h" -#include "mem0mem.h" -#include "sync0sync.h" - -ulint ulint_array[200000]; - -void -test1(void) -{ - hash_table_t* table1; - ulint i; - ulint n313 = 313; - ulint n414 = 414; - - printf("------------------------------------------------\n"); - printf("TEST 1. BASIC TEST\n"); - - table1 = ha_create(50000); - - ha_insert_for_fold(table1, 313, &n313); - - ha_insert_for_fold(table1, 313, &n414); - - ut_a(ha_validate(table1)); - - ha_delete(table1, 313, &n313); - ha_delete(table1, 313, &n414); - - ut_a(ha_validate(table1)); - - printf("------------------------------------------------\n"); - printf("TEST 2. TEST OF MASSIVE INSERTS AND DELETES\n"); - - table1 = ha_create(10000); - - for (i = 0; i < 200000; i++) { - ulint_array[i] = i; - } - - for (i = 0; i < 50000; i++) { - ha_insert_for_fold(table1, i * 7, ulint_array + i); - } - - ut_a(ha_validate(table1)); - - for (i = 0; i < 50000; i++) { - ha_delete(table1, i * 7, ulint_array + i); - } - - ut_a(ha_validate(table1)); -} - -void -test2(void) -{ - hash_table_t* table1; - ulint i; - ulint oldtm, tm; - ha_node_t* node; - - printf("------------------------------------------------\n"); - printf("TEST 3. SPEED TEST\n"); - - table1 = ha_create(300000); - - oldtm = ut_clock(); - - for (i = 0; i < 200000; i++) { - ha_insert_for_fold(table1, i * 27877, ulint_array + i); - } - - tm = ut_clock(); - - printf("Wall clock time for %lu inserts %lu millisecs\n", - i, tm - oldtm); - - oldtm = ut_clock(); - - for (i = 0; i < 200000; i++) { - node = ha_search(table1, i * 27877); - } - - tm = ut_clock(); - - printf("Wall clock time for %lu searches %lu millisecs\n", - i, tm - oldtm); - - oldtm = ut_clock(); - - for (i = 0; i < 200000; i++) { - ha_delete(table1, i * 27877, ulint_array + i); - } - - tm = ut_clock(); - - printf("Wall clock time for %lu deletes %lu millisecs\n", - i, tm - oldtm); -} - -void -main(void) -{ - sync_init(); - mem_init(1000000); - - test1(); - - test2(); - - printf("TESTS COMPLETED SUCCESSFULLY!\n"); -} |