Constructing a Hash Table
Moderator: General Moderators
Constructing a Hash Table
I have two columns in my table. Both of them contains strings whose maximum length can be 16 characters. The number of records are close to a million. I need to make some comparisons between the two columns. To do this, I'm thinking of constructing a Hash Table. How would I do it? Never worked with hashes before, so can someone please guide me?
Internals and Portability
Written in C and C++.
Uses GNU Automake (1.4), Autoconf (Version 2.52 or newer), and Libtool for portability.
Works on many different platforms; APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl.
Fully multi-threaded using kernel threads, this means it can easily use multiple CPUs if available.
Very fast B-tree disk tables with index compression and thread-based memory allocation system.
Very fast joins using an optimised one-sweep multi-join, can mix tables from different databases in the same query.
In-memory hash tables which are used as temporary tables.
SQL functions are implemented through a highly optimised class library and should be as fast as possible!
Usually there isn't any memory allocation at all after query initialisation.
There are 10 types of people in this world, those who understand binary and those who don't
Re: Constructing a Hash Table
I don't see why you think you need a hash table. You are using a database let the database do the indexing for you.legend986 wrote:I have two columns in my table. Both of them contains strings whose maximum length can be 16 characters. The number of records are close to a million. I need to make some comparisons between the two columns. To do this, I'm thinking of constructing a Hash Table. How would I do it? Never worked with hashes before, so can someone please guide me?
Hash tables are great at in-memory retrieval. PHP arrays are implemented as hash tables (basically) so in fact you have worked with hashes. If you are interested in learning more on hash tables the [http://en.wikipedia.org/wiki/Hash_tables]article[/url] on Wikipedia is pretty good.
If your data is small enough to fit in memory you might benefit from a MySQL heap table (assuming you are using MySQL) but I would suggest against it in most cases.
Please submit more details on the problem you are having and maybe we could be of more help.